forked from NetCZ/vue-pikaday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
89 lines (84 loc) · 1.99 KB
/
rollup.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
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
86
87
88
89
import path from 'path';
import camelCase from 'lodash/camelCase';
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import copy from 'rollup-plugin-copy';
import { peerDependencies, scope, name as nameWithScope } from './package.json';
const name = nameWithScope.replace(`@${ scope }/`, '');
const base = path.resolve(__dirname, './');
const src = path.resolve(base, 'src');
const dist = path.resolve(base, 'dist');
const debug = process.env.DEBUG === 'true';
const baseConfig = {
input: path.resolve(src, 'index.js'),
external: Object.keys(peerDependencies),
plugins: [
resolve({ external: ['vue'] }),
babel({
babelrc: false,
presets: [
['@babel/preset-env', { 'modules': false }],
'@babel/preset-flow'
],
exclude: 'node_modules/**'
}),
commonjs(),
postcss({
extract: dist + '/vue-pikaday.min.css',
minimize: true
}),
copy({
targets: {
'node_modules/pikaday/css/pikaday.css': dist + '/vue-pikaday.css'
}
}),
terser({
mangle: {
reserved: ['Pikaday', 'moment']
},
compress: {
drop_console: !debug,
drop_debugger: !debug
}
})
]
};
export default [
{
...baseConfig,
output: {
format: 'cjs',
name: camelCase(name),
file: path.resolve(dist, name + '.common.js'),
sourcemap: true,
globals: {
moment: 'moment',
pikaday: 'Pikaday'
},
},
},
{
...baseConfig,
output: {
format: 'umd',
name: camelCase(name),
file: path.resolve(dist, name + '.js'),
sourcemap: true,
globals: {
moment: 'moment',
pikaday: 'Pikaday'
},
}
},
{
...baseConfig,
output: {
format: 'es',
file: path.resolve(dist, name + '.esm.js'),
sourcemap: true
}
}
];