|
| 1 | +import { babel } from '@rollup/plugin-babel'; |
| 2 | +import commonjs from '@rollup/plugin-commonjs'; |
| 3 | +import { nodeResolve } from '@rollup/plugin-node-resolve'; |
| 4 | +import terser from '@rollup/plugin-terser'; |
| 5 | +import typescript from 'rollup-plugin-typescript2'; |
| 6 | +import dts from 'rollup-plugin-dts'; |
| 7 | + |
| 8 | +const packageJson = require('./package.json'); |
| 9 | + |
| 10 | +const baseConfig = { |
| 11 | + input: 'src/index.js', |
| 12 | + external: ['axios', 'crypto-js'], |
| 13 | + plugins: [ |
| 14 | + nodeResolve({ |
| 15 | + preferBuiltins: false, |
| 16 | + }), |
| 17 | + commonjs(), |
| 18 | + babel({ |
| 19 | + babelHelpers: 'bundled', |
| 20 | + exclude: 'node_modules/**', |
| 21 | + presets: [['@babel/preset-env', { targets: { node: '14' } }]], |
| 22 | + }), |
| 23 | + ], |
| 24 | +}; |
| 25 | + |
| 26 | +export default [ |
| 27 | + // CommonJS build |
| 28 | + { |
| 29 | + ...baseConfig, |
| 30 | + output: { |
| 31 | + file: packageJson.main, |
| 32 | + format: 'cjs', |
| 33 | + exports: 'named', |
| 34 | + sourcemap: true, |
| 35 | + }, |
| 36 | + plugins: [ |
| 37 | + ...baseConfig.plugins, |
| 38 | + typescript({ |
| 39 | + tsconfig: 'tsconfig.json', |
| 40 | + useTsconfigDeclarationDir: true, |
| 41 | + }), |
| 42 | + ], |
| 43 | + }, |
| 44 | + // ES Module build |
| 45 | + { |
| 46 | + ...baseConfig, |
| 47 | + output: { |
| 48 | + file: packageJson.module, |
| 49 | + format: 'es', |
| 50 | + sourcemap: true, |
| 51 | + }, |
| 52 | + plugins: [ |
| 53 | + ...baseConfig.plugins, |
| 54 | + typescript({ |
| 55 | + tsconfig: 'tsconfig.json', |
| 56 | + useTsconfigDeclarationDir: true, |
| 57 | + }), |
| 58 | + ], |
| 59 | + }, |
| 60 | + // UMD build (minified) |
| 61 | + { |
| 62 | + ...baseConfig, |
| 63 | + output: { |
| 64 | + file: 'dist/index.umd.js', |
| 65 | + format: 'umd', |
| 66 | + name: 'LicenseChain', |
| 67 | + sourcemap: true, |
| 68 | + }, |
| 69 | + plugins: [ |
| 70 | + ...baseConfig.plugins, |
| 71 | + typescript({ |
| 72 | + tsconfig: 'tsconfig.json', |
| 73 | + useTsconfigDeclarationDir: true, |
| 74 | + }), |
| 75 | + terser(), |
| 76 | + ], |
| 77 | + }, |
| 78 | + // TypeScript definitions |
| 79 | + { |
| 80 | + input: 'src/index.ts', |
| 81 | + output: { |
| 82 | + file: packageJson.types, |
| 83 | + format: 'es', |
| 84 | + }, |
| 85 | + plugins: [dts()], |
| 86 | + external: [/\.css$/], |
| 87 | + }, |
| 88 | +]; |
| 89 | + |
0 commit comments