forked from zuoez02/siyuan-plugin-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
60 lines (59 loc) · 1.66 KB
/
vite.config.js
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
// vite.config.js
import { resolve } from 'path';
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { replaceCodePlugin } from 'vite-plugin-replace';
import packageJson from './package.json';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
export default defineConfig({
plugins: [
svelte(),
replaceCodePlugin({
replacements: [
{
from: '__VERSION__',
to: packageJson.version,
},
],
}),
cssInjectedByJsPlugin(),
],
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, 'src/index.js'),
name: 'SiYuan',
// the proper extensions will be added
fileName: 'main',
},
resolve: {
alias: {
'@': resolve('src'),
},
},
server: {
host: '0.0.0.0',
port: 8090,
watch: {},
hmr: true,
},
build: {
assetsDir: '',
emptyOutDir: false,
lib: {
entry: process.env.TYPE === 'iife' ? 'src/index.ts' : 'src/export',
formats: process.env.TYPE === 'iife' ? ['iife'] : ['es'],
name: 'siyuan-plugin-system',
fileName: (t, v) => t === 'iife' ? 'main.js' : 'main.esm.js',
},
outDir: '',
rollupOptions: {
output: {
name: 'main',
dir: 'out'
},
},
//构建后是否生成 source map 文件
sourcemap: 'inline',
minify: 'terser', //terser 构建后文件体积更小
},
});