forked from KonghaYao/cn-font-split
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.mts
More file actions
71 lines (69 loc) · 2.2 KB
/
vite.config.mts
File metadata and controls
71 lines (69 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { defineConfig } from 'vite';
import nodeExternals from 'rollup-plugin-node-externals';
import dts from 'vite-plugin-dts';
import fs from 'fs-extra';
try {
fs.unlinkSync('./src/version');
} catch (e) {}
export default defineConfig(({ mode }) => {
return {
base: '',
plugins: [
mode === 'production' &&
nodeExternals({
builtinsPrefix: 'ignore',
include: ['bun:ffi'],
exclude: [
'memfs-browser',
'@xan105/ffi/koffi',
'@tybys/wasm-util',
],
}),
dts({
include: ['src/**/*', '../ffi/gen/index.ts'],
exclude: ['src/*.test.ts'],
}),
{
name: 'add deps',
transform(code, id) {
if (mode === 'production' && id.includes('memfs')) {
return 'import { Buffer } from "buffer";\n' + code;
}
if (id.includes('wasm-util.esm')) {
return code.replaceAll(
'process.env',
'import.meta.env',
);
}
},
},
],
build: {
target: 'esnext',
lib: {
entry: [
'./src/node/index.ts',
'./src/node/init.ts',
'./src/bun/index.ts',
'./src/bun/init.ts',
'./src/deno/index.ts',
'./src/wasm/index.ts',
'./src/cli.ts',
],
formats: ['es', 'cjs'],
},
minify: false, // 禁用代码混淆
sourcemap: false,
assetsDir: '',
assetsInlineLimit: 0,
rollupOptions: {
output: {
assetFileNames: `[name]-[hash].[ext]`,
exports: 'named',
preserveModules: true,
preserveModulesRoot: './src',
},
},
},
};
});