Untitled

mail@pastecode.io avatar
unknown
javascript
6 months ago
651 B
6
Indexable
Never
import path from 'path';
import fs from 'fs/promises';

const postProcessIndex = () => {
	let config;
  	return {
    	name: 'post-process-index',
    	configResolved: async (resolvedConfig) => {
    		config = resolvedConfig;
    	},
		closeBundle: async () => {
			try {
				const filePath = path.join(config.root, '.histoire/dist/index.html');
            	await fs.access(filePath);
            	let file = await fs.readFile(filePath, { encoding: 'utf8' });
            	file = file.replace(/<\/head>/, '<meta name="key" content="value"></head>');
            	await fs.writeFile(filePath, file);
			} catch {
			}
		}
  	}
} 
Leave a Comment