Commit | Line | Data |
---|---|---|
7977150f | 1 | import typescript from 'rollup-plugin-typescript2' |
f45e4999 JB |
2 | import analyze from 'rollup-plugin-analyzer' |
3 | import { terser } from 'rollup-plugin-terser' | |
660940b0 | 4 | import del from 'rollup-plugin-delete' |
660940b0 JB |
5 | |
6 | const isDevelopmentBuild = process.env.BUILD === 'development' | |
f4162974 | 7 | const isAnalyze = process.env.ANALYZE |
660940b0 JB |
8 | |
9 | export default { | |
10 | input: 'src/index.ts', | |
f4162974 JB |
11 | output: { |
12 | ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }), | |
13 | format: 'cjs', | |
14 | sourcemap: !!isDevelopmentBuild, | |
15 | ...(isDevelopmentBuild && { preserveModules: true }), | |
16 | ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }), | |
17 | ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }) | |
18 | }, | |
660940b0 JB |
19 | external: ['async_hooks', 'cluster', 'events', 'worker_threads'], |
20 | plugins: [ | |
7977150f | 21 | typescript({ |
660940b0 JB |
22 | tsconfig: isDevelopmentBuild |
23 | ? 'tsconfig.development.json' | |
24 | : 'tsconfig.json' | |
25 | }), | |
26 | del({ | |
f4162974 | 27 | targets: ['lib/*'] |
f45e4999 | 28 | }), |
f4162974 | 29 | isAnalyze && analyze() |
660940b0 JB |
30 | ] |
31 | } |