-
Notifications
You must be signed in to change notification settings - Fork 658
/
rollup.config.js
75 lines (69 loc) · 1.85 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 replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';
import { babel } from '@rollup/plugin-babel';
import minimist from 'minimist';
import vue from 'rollup-plugin-vue';
import alias from 'rollup-plugin-alias';
import PostCSS from 'rollup-plugin-postcss';
// import css from 'rollup-plugin-css-only';
//import nodeResolve from '@rollup/plugin-node-resolve';
const argv = minimist(process.argv.slice(2));
let vue_path = 'node_modules/vue/dist/vue.esm-browser.js';
if (argv && argv.prod) {
vue_path = 'node_modules/vue/dist/vue.esm-browser.prod.js'
}
let buildFormat = {
input: './http_src/ntopng.js',
plugins: [
// nodeResolve(),
replace({
'process.env.NODE_ENV': JSON.stringify( 'production' )
}),
// vue({ css: true }),
// css({ output: "test.css"}),
// Process only `<style module>` blocks.
vue(),
PostCSS({
modules: {
generateScopedName: '[local]___[hash:base64:5]',
},
include: /&module=.*\.css$/,
}),
// Process all `<style>` blocks except `<style module>`.
PostCSS({ include: /(?<!&module=.*)\.css$/ }),
alias({
entries: [
{ find: "vue", replacement: vue_path }
]
}),
],
// external: ["vue", "Vue"],
// globals: { vue: "Vue", },
output: {
file: './httpdocs/dist/ntopng.js',
format: 'iife',
name: 'ntopng',
// globals: { vue: "Vue", },
// exports: "auto",
sourcemap: argv && argv.prod ? "inline" : false,
},
watch: {
chokidar: {
},
exclude: ['node_modules/**']
}
};
if (argv && argv.prod) {
let babelPlugin = babel({
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
babelHelpers: 'bundled'
});
let terserPlugin = terser({
output: {
ecma: 5,
},
});
buildFormat.plugins.push(babelPlugin);
buildFormat.plugins.push(terserPlugin);
}
export default buildFormat;