-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
45 lines (40 loc) · 1.09 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
import typescript from 'rollup-plugin-typescript2';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import merge from 'deepmerge';
const jsConf = {
input: './src/main.js',
output: {
file: './dist/bundle.js',
sourcemap: true,
name: 'SomeName',
format: 'iife'
},
plugins: [
resolve({
browser: true
}),
commonjs({
include: 'node_modules/**',
})
]
}
const postTscConf = merge({}, jsConf);
postTscConf.input = postTscConf.input.replace('/src/', '/tsc_output/');
const tsPluginConf = merge({}, jsConf);
tsPluginConf.input = tsPluginConf.input.replace('.js', '.ts');
tsPluginConf.plugins.splice(0, 0, typescript());
tsPluginConf.plugins.splice(tsPluginConf.plugins.length - 1, 0, json());
let conf = null;
switch (process.env.NODE_ENV) {
case 'js':
conf = jsConf;
break;
case 'tsPlugin':
conf = tsPluginConf;
break;
default:
conf = postTscConf;
}
export default conf;