-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
rollup.config.js
41 lines (38 loc) · 1020 Bytes
/
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
import { terser } from 'rollup-plugin-terser';
import replace from '@rollup/plugin-replace';
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import pkg from './package.json';
const DEV = !!process.env.ROLLUP_WATCH;
const VERSION = `"${pkg.version}"`;
function getConfigByEnv(env) {
return {
input: 'src/index.js',
output: [{
name: 'Nude',
dir: `./dist/${env ==='development' ? 'dev/' : ''}`,
format: 'es',
}],
plugins: [
replace({
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify(env),
'process.env.APP_VERSION': VERSION,
},
}),
env === 'development' ? undefined : terser(),
commonjs(),
svelte(),
resolve(),
json(),
]
}
}
export default [
getConfigByEnv('development'),
].concat(!DEV ? [
getConfigByEnv('production')
] : []);