-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
75 lines (69 loc) · 1.84 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
import cjs from '@rollup/plugin-commonjs';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import { terser } from 'rollup-plugin-terser';
import css from './build/css';
import nodeResolve from './build/resolve';
import babel from './build/babel';
const isProduction = !process.env.ROLLUP_WATCH;
export default () => {
let config = [
{
input: 'src/main.ts',
output: { format: 'esm', file: 'dist/vectre.esm.js' },
external: (id) => {
return /core|^vue$/.test(id);
},
plugins: [nodeResolve(), cjs(), css(), babel()],
},
{
input: 'src/main.ts',
output: { format: 'cjs', file: 'dist/vectre.cjs.js' },
external: (id) => {
return /core|^vue$/.test(id);
},
plugins: [nodeResolve(), cjs(), css(), babel()],
},
{
input: 'src/plugin.ts',
output: {
format: 'umd',
file: 'dist/vectre.js',
name: 'Vectre',
exports: 'default',
globals: {
vue: 'Vue',
},
},
external: ['vue'],
plugins: [nodeResolve(), cjs(), css(), babel(false, true)],
},
{
input: 'src/plugin.ts',
output: {
format: 'umd',
file: 'dist/vectre.legacy.js',
name: 'Vectre',
exports: 'default',
globals: {
vue: 'Vue',
},
},
external: ['vue'],
plugins: [nodeResolve(), cjs(), css(), babel(false, true, true)],
},
];
config.forEach((c) => c.plugins.push(sizeSnapshot()));
config
.filter((c) => c.output.format === 'umd')
.forEach((c) => {
config.push({
...c,
output: { ...c.output, file: c.output.file.replace(/\.js/g, '.min.js') },
plugins: [...c.plugins, terser()],
});
});
if (!isProduction) {
config = config.filter((c) => c.output.format === 'esm');
}
return config;
};