This commit is contained in:
手瓜一十雪 2024-11-16 11:39:12 +08:00
parent e34b60315c
commit 25751b8149

View File

@ -3,14 +3,12 @@ import { defineConfig, PluginOption, UserConfig } from 'vite';
import { resolve } from 'path'; import { resolve } from 'path';
import nodeResolve from '@rollup/plugin-node-resolve'; import nodeResolve from '@rollup/plugin-node-resolve';
import { builtinModules } from 'module'; import { builtinModules } from 'module';
//依赖排除
const external = ['silk-wasm', 'ws', 'express', 'qrcode-terminal', 'fluent-ffmpeg', 'piscina']; const external = ['silk-wasm', 'ws', 'express', 'qrcode-terminal', 'fluent-ffmpeg'];
const nodeModules = [...builtinModules, builtinModules.map(m => `node:${m}`)].flat(); const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
function genCpModule(module: string) { function genCpModule(module: string) {
return { src: `./node_modules/${module}`, dest: `dist/node_modules/${module}`, flatten: false }; return { src: `./node_modules/${module}`, dest: `dist/node_modules/${module}`, flatten: false };
} }
let startScripts: string[] | undefined = undefined; let startScripts: string[] | undefined = undefined;
if (process.env.NAPCAT_BUILDSYS == 'linux') { if (process.env.NAPCAT_BUILDSYS == 'linux') {
startScripts = []; startScripts = [];
@ -19,7 +17,6 @@ if (process.env.NAPCAT_BUILDSYS == 'linux') {
} else { } else {
startScripts = ['./script/KillQQ.bat']; startScripts = ['./script/KillQQ.bat'];
} }
const FrameworkBaseConfigPlugin: PluginOption[] = [ const FrameworkBaseConfigPlugin: PluginOption[] = [
cp({ cp({
targets: [ targets: [
@ -68,14 +65,14 @@ const ShellBaseConfig = () =>
target: 'esnext', target: 'esnext',
minify: false, minify: false,
lib: { lib: {
entry: { entry: 'src/shell/napcat.ts',
'napcat': 'src/shell/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
},
formats: ['es'], formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`, fileName: () => 'napcat.mjs',
} },
} rollupOptions: {
external: [...nodeModules, ...external],
},
},
}); });
const FrameworkBaseConfig = () => const FrameworkBaseConfig = () =>
@ -93,14 +90,14 @@ const FrameworkBaseConfig = () =>
target: 'esnext', target: 'esnext',
minify: false, minify: false,
lib: { lib: {
entry: { entry: 'src/framework/napcat.ts',
'napcat': 'src/framework/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
},
formats: ['es'], formats: ['es'],
fileName: (_, entryName) => `${entryName}.mjs`, fileName: () => 'napcat.mjs',
}, },
} rollupOptions: {
external: [...nodeModules, ...external],
},
},
}); });
export default defineConfig(({ mode }): UserConfig => { export default defineConfig(({ mode }): UserConfig => {