mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-11-30 18:27:40 +08:00
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { rollup } from 'rollup'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import css from 'rollup-plugin-css-only'
|
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
import commonjs from '@rollup/plugin-commonjs'
|
|
import esbuild from 'rollup-plugin-esbuild'
|
|
import filesize from 'rollup-plugin-filesize'
|
|
import glob from 'fast-glob'
|
|
import { epRoot, pkgRoot } from './utils/paths'
|
|
import { ElementPlusAlias } from './plugins/element-plus-alias'
|
|
import { generateExternal, writeBundles } from './utils/rollup'
|
|
import { excludeFiles } from './utils/pkg'
|
|
import { reporter } from './plugins/size-reporter'
|
|
import { buildConfigEntries, target } from './build-info'
|
|
import type { OutputOptions } from 'rollup'
|
|
|
|
export const buildModules = async () => {
|
|
const input = excludeFiles(
|
|
await glob('**/*.{js,ts,vue}', {
|
|
cwd: pkgRoot,
|
|
absolute: true,
|
|
onlyFiles: true,
|
|
})
|
|
)
|
|
const bundle = await rollup({
|
|
input,
|
|
plugins: [
|
|
ElementPlusAlias(),
|
|
css(),
|
|
vue({
|
|
isProduction: false,
|
|
}),
|
|
nodeResolve({
|
|
extensions: ['.mjs', '.js', '.json', '.ts'],
|
|
}),
|
|
commonjs(),
|
|
esbuild({
|
|
sourceMap: true,
|
|
target,
|
|
loaders: {
|
|
'.vue': 'ts',
|
|
},
|
|
}),
|
|
filesize({ reporter }),
|
|
],
|
|
external: await generateExternal({ full: false }),
|
|
treeshake: false,
|
|
})
|
|
await writeBundles(
|
|
bundle,
|
|
buildConfigEntries.map(([module, config]): OutputOptions => {
|
|
return {
|
|
format: config.format,
|
|
dir: config.output.path,
|
|
exports: module === 'cjs' ? 'named' : undefined,
|
|
preserveModules: true,
|
|
preserveModulesRoot: epRoot,
|
|
sourcemap: true,
|
|
entryFileNames: `[name].${config.ext}`,
|
|
}
|
|
})
|
|
)
|
|
}
|