-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
76 lines (72 loc) · 1.42 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
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import filesize from 'rollup-plugin-filesize';
import postcss from 'rollup-plugin-postcss';
import aggregateExports from 'rollup-plugin-aggregate-exports';
import vue2 from 'rollup-plugin-vue2';
import vue3 from 'rollup-plugin-vue3';
const { plugins: postcssPlugins } = require('./postcss.config.js');
const isProduction = process.env.NODE_ENV === 'production';
const rollupConfig = [
{
label: 'vue2',
vue: vue2({
css: false,
style: {
postcssModulesOptions: {
generateScopedName: '[hash:base64:4]',
},
postcssPlugins,
},
}),
},
{
label: 'vue3',
vue: vue3({
cssModulesOptions: {
generateScopedName: '[hash:base64:4]',
},
}),
},
].map(({ label, vue }) => ({
input: 'src/SplitView.vue',
plugins: [
vue,
postcss({
extract: 'style.css',
minimize: true,
plugins: postcssPlugins,
}),
babel({
babelHelpers: 'bundled',
}),
isProduction && terser(),
isProduction && filesize(),
aggregateExports({
fileName: `${label}.js`,
exports: [
{
identifier: 'default',
from: `./${label}.esm.js`,
},
'./style.css',
],
}),
],
external: 'vue',
output: [
{
format: 'es',
file: `dist/${label}.esm.js`,
},
{
format: 'umd',
file: `dist/${label}.umd.js`,
name: 'SplitView',
globals: {
vue: 'vue',
},
},
],
}));
export default rollupConfig;