-
Notifications
You must be signed in to change notification settings - Fork 27
/
rollup.config.example.mjs
59 lines (57 loc) · 1.26 KB
/
rollup.config.example.mjs
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
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import run from '@rollup/plugin-run';
import replace from '@rollup/plugin-replace';
import builtins from 'builtin-modules';
const commonPlugins = [
replace({
values: {
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
},
preventAssignment: true,
}),
commonjs({
ignoreDynamicRequires: true,
}),
resolve(),
json(),
typescript({ tsconfig: './tsconfig.json' }),
];
export default [
{
input: 'example/client/index.tsx',
output: {
file: 'dist/browser.js',
format: 'iife',
sourcemap: true,
},
plugins: [
...commonPlugins,
serve({
open: false,
verbose: true,
contentBase: ['.', './example/client'],
host: 'localhost',
port: 3000,
historyApiFallback: true,
}),
livereload({ watch: 'dist' }),
],
external: builtins,
},
{
input: 'example/server/index.ts',
output: {
inlineDynamicImports: true,
file: 'dist/server.js',
format: 'cjs',
sourcemap: true,
},
plugins: [...commonPlugins, run()],
external: builtins,
},
];