-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
58 lines (50 loc) · 1.11 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
46
47
48
49
50
51
52
53
54
55
56
57
58
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import serve from 'rollup-plugin-server';
const processArguments = process.argv;
let buildTarget = 'cdn' | 'nodePackage';
let devMode = false;
processArguments.forEach((arg) => {
if (arg.includes('buildType=cdn')) {
buildTarget = 'cdn';
}
if (arg.includes('mode=dev')) {
devMode = true;
}
});
const inputFile = buildTarget === 'cdn' ? './src/cdn.ts' : './src/index.ts';
const outputFile = buildTarget === 'cdn' ? 'dist/cdn.js' : 'dist/index.js';
const plugins = [
nodeResolve(),
commonjs({
include: 'node_modules/**'
}),
typescript({
tsconfig: './tsconfig.json'
}),
terser()
];
if (devMode) {
plugins.push(
serve({
port: 9200,
contentBase: ['dist']
})
);
}
function config() {
return [
{
input: inputFile,
output: {
file: outputFile,
format: 'esm',
sourcemap: false
},
plugins
}
];
}
export default config;