2021-09-17 15:27:31 +08:00
|
|
|
import path from 'path'
|
2021-08-24 13:36:48 +08:00
|
|
|
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
2021-09-26 01:29:07 +08:00
|
|
|
import { rollup } from 'rollup'
|
2021-08-24 13:36:48 +08:00
|
|
|
import commonjs from '@rollup/plugin-commonjs'
|
|
|
|
import vue from 'rollup-plugin-vue'
|
|
|
|
import esbuild from 'rollup-plugin-esbuild'
|
2021-09-26 01:29:07 +08:00
|
|
|
import replace from '@rollup/plugin-replace'
|
2021-10-18 14:45:57 +08:00
|
|
|
import filesize from 'rollup-plugin-filesize'
|
2021-09-27 15:24:45 +08:00
|
|
|
import { parallel } from 'gulp'
|
2021-10-18 14:45:57 +08:00
|
|
|
import { version } from '../packages/element-plus/version'
|
|
|
|
import { RollupResolveEntryPlugin } from './plugins/rollup-plugin-entry'
|
2021-09-26 01:29:07 +08:00
|
|
|
import { epRoot, epOutput } from './utils/paths'
|
2021-10-18 14:45:57 +08:00
|
|
|
import { generateExternal, writeBundles } from './utils/rollup'
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-10-18 14:45:57 +08:00
|
|
|
import { withTaskName } from './utils/gulp'
|
2021-09-26 01:29:07 +08:00
|
|
|
|
2021-09-27 15:24:45 +08:00
|
|
|
export const buildFull = (minify: boolean) => async () => {
|
2021-10-18 14:45:57 +08:00
|
|
|
const bundle = await rollup({
|
|
|
|
input: path.resolve(epRoot, 'index.ts'),
|
|
|
|
plugins: [
|
|
|
|
nodeResolve(),
|
|
|
|
vue({
|
|
|
|
target: 'browser',
|
|
|
|
exposeFilename: false,
|
|
|
|
}),
|
|
|
|
commonjs(),
|
|
|
|
esbuild({ minify, sourceMap: minify }),
|
|
|
|
replace({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
|
|
}),
|
|
|
|
await RollupResolveEntryPlugin(),
|
|
|
|
filesize(),
|
|
|
|
],
|
|
|
|
external: await generateExternal({ full: true }),
|
|
|
|
})
|
|
|
|
const banner = `/*! Element Plus v${version} */\n`
|
2021-09-27 15:24:45 +08:00
|
|
|
await writeBundles(bundle, [
|
|
|
|
{
|
|
|
|
format: 'umd',
|
|
|
|
file: path.resolve(epOutput, `dist/index.full${minify ? '.min' : ''}.js`),
|
|
|
|
exports: 'named',
|
|
|
|
name: 'ElementPlus',
|
|
|
|
globals: {
|
|
|
|
vue: 'Vue',
|
|
|
|
},
|
|
|
|
sourcemap: minify,
|
2021-10-18 14:45:57 +08:00
|
|
|
banner,
|
2021-08-25 01:22:03 +08:00
|
|
|
},
|
2021-09-27 15:24:45 +08:00
|
|
|
{
|
|
|
|
format: 'esm',
|
|
|
|
file: path.resolve(
|
|
|
|
epOutput,
|
|
|
|
`dist/index.full${minify ? '.min' : ''}.mjs`
|
|
|
|
),
|
|
|
|
sourcemap: minify,
|
2021-10-18 14:45:57 +08:00
|
|
|
banner,
|
2021-09-27 15:24:45 +08:00
|
|
|
},
|
|
|
|
])
|
2021-09-26 01:29:07 +08:00
|
|
|
}
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-09-27 15:24:45 +08:00
|
|
|
export const buildFullBundle = parallel(
|
|
|
|
withTaskName('buildFullMinified', buildFull(true)),
|
2021-10-18 14:45:57 +08:00
|
|
|
withTaskName('buildFull', buildFull(false))
|
2021-09-26 01:29:07 +08:00
|
|
|
)
|