refactor: Replace Webpack with Vite (#53)
This commit is contained in:
26
utils/plugins/make-manifest.ts
Normal file
26
utils/plugins/make-manifest.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { PluginOption } from 'vite';
|
||||
import manifest from '../../src/manifest';
|
||||
import colorLog from '../log';
|
||||
|
||||
const { resolve } = path;
|
||||
|
||||
const outDir = resolve(__dirname, '..', '..', 'public');
|
||||
|
||||
export default function makeManifest(): PluginOption {
|
||||
return {
|
||||
name: 'make-manifest',
|
||||
buildEnd() {
|
||||
if (!fs.existsSync(outDir)) {
|
||||
fs.mkdirSync(outDir);
|
||||
}
|
||||
|
||||
const manifestPath = resolve(outDir, 'manifest.json');
|
||||
|
||||
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
||||
|
||||
colorLog(`Manifest file copy complete: ${manifestPath}`, 'success');
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user