-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
68 lines (66 loc) · 1.78 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
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import copy from 'rollup-plugin-copy'
import del from 'rollup-plugin-delete'
import livereload from 'rollup-plugin-livereload'
import serve from 'rollup-plugin-serve'
import { terser } from 'rollup-plugin-terser'
import fg from 'fast-glob'
const dev = process.env.NODE_ENV === 'development'
const dir = dev ? 'dist' : 'public'
export default {
input: 'src/js/index.js',
output: {
file: `${dir}/nuclear-fusion.min.js`,
format: 'umd',
sourcemap: false,
},
plugins: [
dev && {
name: 'watch-external',
async buildStart() {
const files = await fg('src/**/*', '!src/**/*.js')
for (let file of files) {
this.addWatchFile(file)
}
},
},
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production'),
}),
del({
targets: `${dir}/*`,
runOnce: true,
verbose: true,
}),
copy({
targets: [
{ src: 'src/index.html', dest: `${dir}` },
{ src: 'src/images/**/*', dest: `${dir}/images` },
{ src: 'src/css/**/*', dest: `${dir}/css` },
{ src: 'src/fonts/**/*', dest: `${dir}/fonts` },
],
}),
nodeResolve({
extensions: ['.js'],
}),
babel({
presets: ['@babel/preset-react'],
babelHelpers: 'bundled',
compact: true,
}),
commonjs(),
json({ compact: true }),
!dev && terser(),
dev &&
serve({
contentBase: 'dist',
historyApiFallback: true,
}),
dev && livereload({ watch: ['dist'], delay: 500 }),
],
}