forked from mengxiong10/vue2-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.locale.config.js
56 lines (50 loc) · 1.25 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
49
50
51
52
53
54
55
56
/* eslint-disable import/no-extraneous-dependencies */
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
const fs = require('fs');
const path = require('path');
const localePath = path.resolve(__dirname, 'src/locale');
const fileList = fs.readdirSync(localePath);
const plugins = [
resolve({
extensions: ['.js', '.json'],
}),
babel({
exclude: 'node_modules/**',
}),
commonjs(),
];
const umd = fileList.map(file => {
const input = path.join(localePath, file);
const external = ['vue2-datepicker'];
const name = path.basename(file, '.js').replace(/-(\w+)/g, (m, p1) => p1.toUpperCase());
return {
input,
plugins,
external,
output: {
file: `locale/${file}`,
format: 'umd',
name: `DatePicker.lang.${name}`,
globals: {
'vue2-datepicker': 'DatePicker',
},
},
};
});
const esm = fileList.map(file => {
const input = path.join(localePath, file);
const external = id => !id.startsWith('.') && !id.startsWith('/');
return {
input,
plugins,
external,
output: {
file: `locale/es/${file}`,
format: 'esm',
exports: 'named',
},
};
});
export default [...esm, ...umd];