-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
66 lines (59 loc) · 1.67 KB
/
rollup.config.ts
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
import { RollupOptions } from 'rollup';
import replace from '@rollup/plugin-replace';
import typescript from 'rollup-plugin-typescript2';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { terser } from "rollup-plugin-terser";
const isProduction = (process.env.NODE_ENV === 'production');
const input = 'src/index.tsx';
const plugins = [
replace({
'process.env.NODE_ENV': JSON.stringify(
isProduction ? 'production' : (process.env.NODE_ENV || 'development')
),
}),
typescript({
check: !isProduction,
typescript: require('typescript'),
tsconfig: (isProduction) ? 'tsconfig.prod.json' : 'tsconfig.json', // Only output sourcemaps on development
}),
nodeResolve(),
commonjs({
include: /node_modules/,
sourceMap: !isProduction, // Only output sourcemaps on development
}),
json(),
];
if (isProduction) {
// terser is slow, only run when building
plugins.push(terser());
}
const config: RollupOptions = {
input,
output: {
file: 'public/bundle.js',
format: 'cjs',
sourcemap: !isProduction, // Only output sourcemaps on development
},
plugins,
// If one of your dependencies generates warnings that you wish to hide from showing up in
// in console, simple uncomment the following and adjust to your needs:
// onwarn: (message) => {
// if ((/Circular dependencies.*ejson/g).test(message) ) {
// return;
// }
//
// return message;
// },
};
if (!isProduction) {
config.watch = {
chokidar: {
useFsEvents: false,
},
include: 'src/**',
clearScreen: false,
};
}
export default config;