|
| 1 | +// import esbuild from 'rollup-plugin-esbuild'; |
| 2 | +import { resolve } from 'path'; |
| 3 | +import vue from 'rollup-plugin-vue'; // 处理vue文件 |
| 4 | +import babel from '@rollup/plugin-babel'; |
| 5 | +import typescript from 'rollup-plugin-typescript2'; |
| 6 | +import postcss from 'rollup-plugin-postcss'; |
| 7 | +// import styles from 'rollup-plugin-styles'; |
| 8 | +import replace from '@rollup/plugin-replace'; |
| 9 | +import { nodeResolve } from '@rollup/plugin-node-resolve'; |
| 10 | +import pkg from '../package.json'; |
| 11 | +import { replacement } from './common.config'; |
| 12 | + |
| 13 | +export const INPUT_PATH = resolve(__dirname, '../packages'); |
| 14 | + |
| 15 | +const deps = Object.keys(pkg.peerDependencies || {}) |
| 16 | + .concat(Object.keys(pkg.dependencies)) |
| 17 | + .concat(Object.keys(pkg.devDependencies)) |
| 18 | + .concat([/node_modules/]); |
| 19 | + |
| 20 | +const genBaseConfig = ({ ts } = {}) => { |
| 21 | + /** |
| 22 | + * @type {import('rollup').RollupOptions} |
| 23 | + */ |
| 24 | + const config = { |
| 25 | + external: deps, |
| 26 | + plugins: [ |
| 27 | + replace({ values: replacement, preventAssignment: true }), |
| 28 | + // vue({ |
| 29 | + // exposeFilename: true, |
| 30 | + // // preprocessStyles: true, |
| 31 | + // }), |
| 32 | + // postcss({ |
| 33 | + // extract: true, |
| 34 | + // }), |
| 35 | + typescript({ ...ts, tsconfig: resolve(__dirname, '../tsconfig.build.json') }), |
| 36 | + babel({ |
| 37 | + babelHelpers: 'runtime', |
| 38 | + skipPreflightCheck: true, |
| 39 | + extensions: ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.vue'], |
| 40 | + }), |
| 41 | + nodeResolve(), |
| 42 | + ], |
| 43 | + }; |
| 44 | + return config; |
| 45 | +}; |
| 46 | + |
| 47 | +export default genBaseConfig; |
0 commit comments