forked from SX-Code/form-designer-naiveui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.locale.js
58 lines (49 loc) · 1.46 KB
/
vite.config.locale.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
import {defineConfig} from 'vite'
import banner from 'vite-plugin-banner'
import {author, license, name, version} from './package.json'
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`) +
' */'
);
}
function toCase(str) {
return str.replace(/(-[a-z])/g, function (v) {
return v.replace('-', '').toLocaleUpperCase();
});
}
function upper(str) {
return str.replace(str[0], str[0].toLocaleUpperCase());
}
const __banner__ = {
author: `2021-${new Date().getFullYear()} ${author}\n * Github https://github.com/xaboy/form-create-designer`,
license,
name,
version
}
// https://vitejs.dev/config/
export default defineConfig((env) => {
const name = env.mode || 'en';
return {
build: {
outDir: 'locale',
lib: {
entry: `src/locale/${name}.js`,
name: 'FcDesigner' + upper(toCase(name)),
fileName: name,
},
emptyOutDir: false,
},
plugins: [banner(getBanner(__banner__))]
};
})