93 lines
2.6 KiB
JavaScript
93 lines
2.6 KiB
JavaScript
|
const path = require('path');
|
|||
|
const TerserPlugin = require('terser-webpack-plugin')
|
|||
|
const htmlWebpackPlugin = require('html-webpack-plugin');
|
|||
|
module.exports = {
|
|||
|
mode: 'production',
|
|||
|
name: 'yhdesigner-userDefineModule',
|
|||
|
entry: {
|
|||
|
"designer": './src/index.ts',
|
|||
|
"preview": './src/preview.ts'
|
|||
|
},
|
|||
|
output: {
|
|||
|
filename: '[name].js',
|
|||
|
path: path.resolve(__dirname, './dist')
|
|||
|
},
|
|||
|
module: {
|
|||
|
unknownContextCritical: false,
|
|||
|
rules: [
|
|||
|
{
|
|||
|
test: /\.tsx?$/,
|
|||
|
use: ['ts-loader'],
|
|||
|
exclude: /node_modules/
|
|||
|
}, {
|
|||
|
test: /\.css$/,
|
|||
|
use: ['style-loader', 'css-loader']
|
|||
|
},
|
|||
|
{
|
|||
|
test: /\.less$/,
|
|||
|
use: ['style-loader', 'css-loader', 'less-loader']
|
|||
|
},
|
|||
|
{
|
|||
|
test: /\.(gif|png|jpeg|eot|woff|ttf|svg|pdf)$/,
|
|||
|
use: ['file-loader']
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
resolve: {
|
|||
|
extensions: ['.tsx', '.ts', ".js"],
|
|||
|
alias: {
|
|||
|
'vue$': 'vue/dist/vue.esm.js'
|
|||
|
}
|
|||
|
},
|
|||
|
optimization: {
|
|||
|
minimize: true,
|
|||
|
minimizer: [
|
|||
|
new TerserPlugin({
|
|||
|
terserOptions: {
|
|||
|
ecma: 5,
|
|||
|
parse: {},
|
|||
|
warnings: false,
|
|||
|
keep_classnames: true,
|
|||
|
keep_fnames: true,
|
|||
|
compress: {
|
|||
|
drop_console: true,
|
|||
|
drop_debugger: true,
|
|||
|
pure_funcs: ['console.log'] // 移除console
|
|||
|
},
|
|||
|
|
|||
|
},
|
|||
|
extractComments: false
|
|||
|
}),
|
|||
|
]
|
|||
|
},
|
|||
|
performance: {
|
|||
|
hints: 'warning',
|
|||
|
//入口起点的最大体积 整数类型(以字节为单位)
|
|||
|
maxEntrypointSize: 50000000,
|
|||
|
//生成文件的最大体积 整数类型(以字节为单位 300k)
|
|||
|
maxAssetSize: 30000000,
|
|||
|
//只给出 js 文件的性能提示
|
|||
|
assetFilter: function (assetFilename) {
|
|||
|
return assetFilename.endsWith('.css') || assetFilename.endsWith('.js');
|
|||
|
}
|
|||
|
},
|
|||
|
plugins: [
|
|||
|
new htmlWebpackPlugin({
|
|||
|
template: './src/index.html',
|
|||
|
filename: 'index.html',
|
|||
|
inject: 'body',
|
|||
|
chunks: ['designer']
|
|||
|
}),
|
|||
|
new htmlWebpackPlugin({
|
|||
|
template: './src/preview.html',
|
|||
|
filename: 'preview.html',
|
|||
|
inject: 'body',
|
|||
|
chunks: ['preview']
|
|||
|
}),
|
|||
|
],
|
|||
|
externals: {
|
|||
|
jquery: "$",
|
|||
|
lodash: "_",
|
|||
|
echarts: "echarts",
|
|||
|
}
|
|||
|
}
|