-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
56 lines (48 loc) · 1.26 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
// rollup.config.js
// minifying code
import terser from '@rollup/plugin-terser';
// plugins for different module types
// needed if src includes non-ES6 modules
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
// dev support
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
// distribution
const isDist = process.env.DIST == 'true';
const isServe = process.env.SERVE == 'true';
// target directory for build
const target = "html/js";
// name of bundle
const bundle = "layers";
// file extension
const ext = isDist ? "min.js" : "js";
export default {
input: 'src/index.js',
output: [
{
file: `${target}/${bundle}.iife.${ext}`,
format: 'iife',
sourcemap: "inline",
name: `${bundle.toLocaleUpperCase()}`,
},
{
file: `${target}/${bundle}.es.${ext}`,
format: 'es',
},
],
external: [],
plugins: [
resolve(),
commonjs(),
isDist && terser(),
// start dev server and open browser
!isDist && isServe && serve({
open: true, // Opens the browser automatically
contentBase: 'html',
port: 8000,
}),
// dev server livereload browser
!isDist && isServe && livereload({watch : 'html'}),
],
}