-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvite.config.build.js
85 lines (76 loc) · 2.14 KB
/
vite.config.build.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJSX from '@vitejs/plugin-vue-jsx'
import banner from 'vite-plugin-banner'
import cssnano from 'cssnano'
import visualizer from 'rollup-plugin-visualizer';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import {author, license, name, version} from './package.json'
const extnedsPlugins = [];
function getBanner(banner, pkg) {
if (!banner || typeof banner === 'string') {
return banner || '';
}
banner = {...pkg, ...(banner === true ? {} : banner)};
const author =banner.author
const license = banner.license || '';
return (
'/*!\n' +
' * form-create 可视化表单设计器\n' +
` * ${banner.name} v${banner.version}\n` +
` * (c) ${author || ''}\n` +
(license && ` * Released under the ${license} License.\n`) +
' */'
);
}
const __banner__ = {
author: `2021-${new Date().getFullYear()} ${author}\n * Github https://github.com/xaboy/form-create-designer`,
license,
name,
version
}
// 打包生产环境才引入的插件
if (process.env.NODE_ENV === 'production') {
// 打包依赖展示
extnedsPlugins.push(
visualizer({
open: true,
gzipSize: true,
brotliSize: true,
})
);
}
// https://vitejs.dev/config/
export default defineConfig({
build: {
lib: {
entry: 'src/index.js',
name: 'FcDesigner',
fileName: format => `index.${format}.js`,
},
rollupOptions: {
output: {
exports: 'named',
globals: {
vue: 'Vue'
}
},
external: [
'vue',
'naive-ui',
'@form-create/naive-ui'
],
},
brotliSize: true
},
css: {
postcss: {
plugins: [
cssnano({
preset: 'advanced'
})
]
}
},
plugins: [vue(), vueJSX(), banner(getBanner(__banner__)),cssInjectedByJsPlugin(), ...extnedsPlugins]
})