-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
62 lines (57 loc) · 1.68 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
import node_resolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import hotcss from 'rollup-plugin-hot-css';
import commonjs from 'rollup-plugin-commonjs-alternate';
import static_files from 'rollup-plugin-static-files';
import { terser } from 'rollup-plugin-terser';
import refresh from 'rollup-plugin-react-refresh';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import copy from 'rollup-plugin-copy';
import markdown from '@jackfranklin/rollup-plugin-markdown';
let config = {
input: './src/main.js',
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].[hash].js',
assetFileNames: '[name].[hash][extname]'
},
watch: {
exclude: ['public/build/**', 'public/images/**']
},
plugins: [
hotcss({
hot: process.env.NODE_ENV === 'development',
filename: 'styles.css'
}),
babel({
exclude: 'node_modules/**',
presets: ["@babel/preset-react"]
}),
nodePolyfills(),
node_resolve(),
commonjs({
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
}),
process.env.NODE_ENV === 'development' && refresh(),
copy({
targets: [
{ src: 'node_modules/leaflet/dist/images/*', dest: 'public/images' }
]
}),
markdown({
exclude: 'README.md',
})
]
}
if (process.env.NODE_ENV === 'production') {
config.plugins = config.plugins.concat([
static_files({
include: ['./public']
}),
terser()
]);
}
export default config;