element-plus/build/rollup.config.js
hangzou e8c162ea72
fix: fix rollup module (#434)
* fix(build): fix some export & import path

* fix(build): build utils

* fix: fix error import

* fix(build): fix import error

* fix(build): remove useless dependent

* fix(build): fix build command error
2020-10-20 11:45:44 +08:00

57 lines
1.3 KiB
JavaScript

import vue from 'rollup-plugin-vue'
import typescript from 'rollup-plugin-typescript2'
import css from 'rollup-plugin-css-only'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import path from 'path'
import { getPackagesSync } from '@lerna/project'
const inputs = getPackagesSync()
.map(pkg => pkg.name)
.filter(name =>
name.includes('@element-plus') &&
!name.includes('transition') &&
!name.includes('utils'),
)
export default inputs.map(name => ({
input: path.resolve(__dirname, `../packages/${name.split('@element-plus/')[1]}/index.ts`),
output: {
format: 'es',
file: `lib/${name.split('@element-plus/')[1]}/index.js`,
paths(id) {
if (/^@element-plus/.test(id)) {
return id.replace('@element-plus', '..')
}
},
},
plugins: [
terser({
module: true,
compress: {
ecma: 2015,
pure_getters: true,
},
}),
nodeResolve(),
commonjs(),
typescript({
tsconfigOverride: {
compilerOptions: {
declaration: false,
},
},
abortOnError: false,
}),
css(),
vue({
target: 'browser',
css: false,
}),
],
external(id) {
return /^vue/.test(id) || /^@element-plus/.test(id)
},
}))