forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.build.locale.ts
64 lines (62 loc) · 1.71 KB
/
vite.config.build.locale.ts
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
import { defineConfig } from 'vite';
import path from 'path';
import config from './package.json';
import vue from '@vitejs/plugin-vue';
import dts from 'vite-plugin-dts';
const banner = `/*!
* ${config.name} v${config.version} ${new Date()}
* (c) 2022 @jdf2e.
* Released under the MIT License.
*/`;
let input = {
index: `./src/packages/locale/index`
};
// 动态读取file name
['zh-CN', 'zh-TW', 'en-US', 'id-ID'].map((file) => {
input[file] = `./src/packages/locale/lang/${file}`;
});
import fs from 'fs-extra';
import { terser } from 'rollup-plugin-terser';
// 构建index.scss 兼容插件市场按需加载插件
fs.outputFile(path.resolve(__dirname, './dist/packages/locale/index.scss'), ' ', 'utf8', (error) => {});
fs.outputFile(path.resolve(__dirname, './dist/packages/locale/lang/index.scss'), ' ', 'utf8', (error) => {});
export default defineConfig({
plugins: [
vue(),
dts({
insertTypesEntry: true,
copyDtsFiles: true,
cleanVueFileName: true,
outputDir: path.resolve(__dirname, './dist/packages/'),
include: path.resolve(__dirname, './src/packages/locale')
})
],
build: {
minify: true,
lib: {
entry: '',
name: 'index',
// fileName: (format) => format,
formats: ['es']
},
rollupOptions: {
// 请确保外部化那些你的库中不需要的依赖
external: ['vue'],
input,
output: {
banner,
dir: path.resolve(__dirname, './dist/packages/locale/lang'),
entryFileNames: '[name].js',
plugins: [
terser({
compress: {
drop_console: true,
drop_debugger: true
}
})
]
}
},
emptyOutDir: false
}
});