mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: build
This commit is contained in:
parent
25751b8149
commit
bd1faccaa8
@ -11,8 +11,12 @@ const ALLOW_SAMPLE_RATE = [8000, 12000, 16000, 24000, 32000, 44100, 48000];
|
|||||||
const EXIT_CODES = [0, 255];
|
const EXIT_CODES = [0, 255];
|
||||||
const FFMPEG_PATH = process.env.FFMPEG_PATH ?? 'ffmpeg';
|
const FFMPEG_PATH = process.env.FFMPEG_PATH ?? 'ffmpeg';
|
||||||
|
|
||||||
|
async function getWorkerPath() {
|
||||||
|
return new URL('./audio-worker.mjs', import.meta.url).href;
|
||||||
|
}
|
||||||
|
|
||||||
const piscina = new Piscina<EncodeArgs, EncodeResult>({
|
const piscina = new Piscina<EncodeArgs, EncodeResult>({
|
||||||
filename: new URL('./audio-worker.mjs', import.meta.url).href,
|
filename: await getWorkerPath(),
|
||||||
});
|
});
|
||||||
|
|
||||||
async function guessDuration(pttPath: string, logger: LogWrapper) {
|
async function guessDuration(pttPath: string, logger: LogWrapper) {
|
||||||
|
@ -4,7 +4,7 @@ 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'];
|
const external = ['silk-wasm', 'ws', 'express', 'qrcode-terminal', 'fluent-ffmpeg', 'piscina'];
|
||||||
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 };
|
||||||
@ -50,55 +50,59 @@ const ShellBaseConfigPlugin: PluginOption[] = [
|
|||||||
nodeResolve(),
|
nodeResolve(),
|
||||||
];
|
];
|
||||||
|
|
||||||
const ShellBaseConfig = () =>
|
const ShellBaseConfig = () => defineConfig({
|
||||||
defineConfig({
|
resolve: {
|
||||||
resolve: {
|
conditions: ['node', 'default'],
|
||||||
conditions: ['node', 'default'],
|
alias: {
|
||||||
alias: {
|
'@/core': resolve(__dirname, './src/core'),
|
||||||
'@/core': resolve(__dirname, './src/core'),
|
'@': resolve(__dirname, './src'),
|
||||||
'@': resolve(__dirname, './src'),
|
'./lib-cov/fluent-ffmpeg': './lib/fluent-ffmpeg',
|
||||||
'./lib-cov/fluent-ffmpeg': './lib/fluent-ffmpeg',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
build: {
|
},
|
||||||
sourcemap: false,
|
build: {
|
||||||
target: 'esnext',
|
sourcemap: false,
|
||||||
minify: false,
|
target: 'esnext',
|
||||||
lib: {
|
minify: false,
|
||||||
entry: 'src/shell/napcat.ts',
|
lib: {
|
||||||
formats: ['es'],
|
entry: {
|
||||||
fileName: () => 'napcat.mjs',
|
'napcat': 'src/shell/napcat.ts',
|
||||||
},
|
'audio-worker': 'src/common/audio-worker.ts',
|
||||||
rollupOptions: {
|
|
||||||
external: [...nodeModules, ...external],
|
|
||||||
},
|
},
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: (_, entryName) => `${entryName}.mjs`,
|
||||||
},
|
},
|
||||||
});
|
rollupOptions: {
|
||||||
|
external: [...nodeModules, ...external],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const FrameworkBaseConfig = () =>
|
const FrameworkBaseConfig = () => defineConfig({
|
||||||
defineConfig({
|
resolve: {
|
||||||
resolve: {
|
conditions: ['node', 'default'],
|
||||||
conditions: ['node', 'default'],
|
alias: {
|
||||||
alias: {
|
'@/core': resolve(__dirname, './src/core'),
|
||||||
'@/core': resolve(__dirname, './src/core'),
|
'@': resolve(__dirname, './src'),
|
||||||
'@': resolve(__dirname, './src'),
|
'./lib-cov/fluent-ffmpeg': './lib/fluent-ffmpeg',
|
||||||
'./lib-cov/fluent-ffmpeg': './lib/fluent-ffmpeg',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
build: {
|
},
|
||||||
sourcemap: false,
|
build: {
|
||||||
target: 'esnext',
|
sourcemap: false,
|
||||||
minify: false,
|
target: 'esnext',
|
||||||
lib: {
|
minify: false,
|
||||||
entry: 'src/framework/napcat.ts',
|
lib: {
|
||||||
formats: ['es'],
|
entry: {
|
||||||
fileName: () => 'napcat.mjs',
|
'napcat': 'src/framework/napcat.ts',
|
||||||
},
|
'audio-worker': 'src/common/audio-worker.ts',
|
||||||
rollupOptions: {
|
|
||||||
external: [...nodeModules, ...external],
|
|
||||||
},
|
},
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: (_, entryName) => `${entryName}.mjs`,
|
||||||
},
|
},
|
||||||
});
|
rollupOptions: {
|
||||||
|
external: [...nodeModules, ...external],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export default defineConfig(({ mode }): UserConfig => {
|
export default defineConfig(({ mode }): UserConfig => {
|
||||||
if (mode === 'shell') {
|
if (mode === 'shell') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user