-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
rollup.locale.config.js
48 lines (43 loc) · 1.11 KB
/
rollup.locale.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
import typescript from 'rollup-plugin-typescript2';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import fs from 'fs';
import path from 'path';
const localePath = path.resolve(__dirname, 'lib/locale');
const fileList = fs.readdirSync(localePath);
const plugins = [
nodeResolve(),
typescript({
useTsconfigDeclarationDir: true,
tsconfig: 'tsconfig.locale.json',
}),
];
export function camelcase(str) {
const camelizeRE = /-(\w)/g;
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
}
const config = fileList.map((file) => {
const input = path.join(localePath, file);
const external = ['vue-datepicker-next'];
const filename = path.basename(file, '.ts');
return {
input,
plugins,
external,
output: [
{
file: `locale/${filename}.js`,
format: 'umd',
name: `DatePicker.lang.${camelcase(filename)}`,
globals: {
'vue-datepicker-next': 'DatePicker',
},
},
{
file: `locale/${filename}.es.js`,
format: 'esm',
exports: 'named',
},
],
};
});
export default config;