element-plus/build/webpack.config.js

65 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-09-15 16:10:32 +08:00
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const { VueLoaderPlugin } = require('vue-loader')
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
2020-09-15 16:10:32 +08:00
const libMode = process.env.LIBMODE
const isFullMode = libMode === 'full'
let externals = [
{
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
},
},
]
if (!isFullMode) {
externals.push({
'@popperjs/core': '@popperjs/core',
'async-validator': 'async-validator',
'mitt': 'mitt',
'normalize-wheel': 'normalize-wheel',
'resize-observer-polyfill': 'resize-observer-polyfill',
},
/^dayjs.*/,
/^lodash.*/)
}
const config = {
mode: 'production',
2020-09-15 17:12:16 +08:00
entry: path.resolve(__dirname, '../packages/element-plus/index.ts'),
2020-09-15 16:10:32 +08:00
output: {
path: path.resolve(__dirname, '../lib'),
publicPath: '/',
filename: isFullMode ? 'index.full.js' : 'index.js',
2020-09-15 17:12:16 +08:00
libraryTarget: 'umd',
2020-10-16 14:33:43 +08:00
library: 'ElementPlus',
2020-09-15 17:12:16 +08:00
umdNamedDefine: true,
globalObject: 'typeof self !== \'undefined\' ? self : this',
2020-09-15 16:10:32 +08:00
},
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader',
},
{
test: /\.(ts|js)x?$/,
2020-09-15 16:10:32 +08:00
exclude: /node_modules/,
loader: 'babel-loader',
2020-09-15 16:10:32 +08:00
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
2020-09-15 16:10:32 +08:00
},
externals,
2020-09-15 16:10:32 +08:00
plugins: [
new VueLoaderPlugin(),
// new BundleAnalyzerPlugin(),
2020-09-15 16:10:32 +08:00
],
}
module.exports = config