Commit | Line | Data |
---|---|---|
8f98d75d JB |
1 | import terser from '@rollup/plugin-terser' |
2 | import typescript from '@rollup/plugin-typescript' | |
f45e4999 | 3 | import analyze from 'rollup-plugin-analyzer' |
5ea22628 | 4 | import command from 'rollup-plugin-command' |
eae1fc25 | 5 | import del from 'rollup-plugin-delete' |
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' }), | |
8f98d75d | 19 | ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }) |
f4162974 | 20 | }, |
23ff945a | 21 | external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'], |
660940b0 | 22 | plugins: [ |
8f98d75d | 23 | typescript({ |
660940b0 JB |
24 | tsconfig: isDevelopmentBuild |
25 | ? 'tsconfig.development.json' | |
ce68dd22 | 26 | : 'tsconfig.production.json' |
660940b0 JB |
27 | }), |
28 | del({ | |
f4162974 | 29 | targets: ['lib/*'] |
f45e4999 | 30 | }), |
5ea22628 JB |
31 | isAnalyze && analyze(), |
32 | isDocumentation && command('npm run typedoc') | |
660940b0 JB |
33 | ] |
34 | } |