-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
70 lines (61 loc) · 1.62 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
67
68
69
70
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";
import run from '@rollup/plugin-run';
const pkg = require('./package.json');
const isProduction = (process.env.NODE_ENV === 'production');
const input = './server.ts';
const plugins = [
replace({
'process.env.NODE_ENV': JSON.stringify(
isProduction ? 'production' : (process.env.NODE_ENV || 'development')
),
}),
typescript({
check: !isProduction,
typescript: require('typescript'),
}),
nodeResolve(),
commonjs({
sourceMap: !isProduction, // Only output sourcemaps on development
}),
json(),
];
if (isProduction) {
// terser is slow, only run when building
plugins.push(terser());
}
if (!isProduction) {
plugins.push(run({
execArgv: ['-r', 'source-map-support/register', '--inspect'],
}));
}
const config: RollupOptions = {
input,
output: {
file: 'bin/server.js',
format: 'cjs',
exports: 'default',
sourcemap: !isProduction, // Only output sourcemaps on development
},
plugins,
// indicate here external modules you don't want to include in your bundle (i.e.: 'lodash')
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
],
};
if (!isProduction) {
config.watch = {
chokidar: {
useFsEvents: false,
},
include: 'server.ts',
clearScreen: false,
};
}
export default config;