-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.dev.config.js
More file actions
60 lines (55 loc) · 1.39 KB
/
rollup.dev.config.js
File metadata and controls
60 lines (55 loc) · 1.39 KB
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
import typescript from 'rollup-plugin-typescript2';
import { terser } from 'rollup-plugin-terser';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import replace from 'rollup-plugin-replace';
import path from 'path';
import pkg from './package.json';
const isProduction = process.env.NODE_ENV === 'production';
const plugins = isProduction ? [
terser(),
] : [
serve('demo'),
livereload({
watch: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'demo'),
path.resolve(__dirname, 'demo-dev'),
],
exts: ['html', 'js', 'tsx', 'ts'],
verbose: true,
}),
];
const config = {
input: './demo-dev/index.tsx',
output: [{
file: './demo/bundle.js',
format: 'iife',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'styled-components': 'styled',
},
}],
external: [
...Object.keys(pkg.peerDependencies),
'styled-components',
],
plugins: [
replace({
'process.env.NODE_ENV': isProduction ? JSON.stringify('production') : JSON.stringify('development'),
}),
typescript({
tsconfig: path.resolve(__dirname, 'tsconfig.dev.json'),
}),
babel(),
commonjs({
include: /node_modules/,
sourceMap: false,
}),
...plugins,
],
};
export default config;