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