-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.base.js
62 lines (59 loc) · 1.41 KB
/
rollup.config.base.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
import vue from 'rollup-plugin-vue';
import commonjs from 'rollup-plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import resolve from 'rollup-plugin-node-resolve';
import { terser as rollupTerser } from 'rollup-plugin-terser';
import image from '@rollup/plugin-image';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import babel from 'rollup-plugin-babel';
const getPlugins = (format, devServe = false) => {
const plugins = [
babel({
exclude: 'node_modules/**',
}),
resolve({ extensions: ['.vue', '.js'] }),
commonjs(),
vue({ css: false }),
postcss({
extract: 'index.css',
plugins: [autoprefixer(), cssnano()],
}),
image(),
rollupTerser({
output: {
comments: false,
},
module: false,
}),
];
if (devServe) {
plugins.push(
serve({
open: true,
contentBase: 'iife',
})
);
plugins.push(livereload());
}
return plugins;
};
export function createOption(format, devServe = false) {
const formatFolder = {
esm: 'es',
cjs: 'dist',
iife: 'iife',
};
return {
input: 'src/index.js',
output: {
file: `${formatFolder[format]}/reception.min.js`,
format,
name: 'reception',
},
plugins: getPlugins(format, devServe),
external: [],
};
}