|
|
@@ -4,6 +4,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
const WebpackMerge = require('webpack-merge')
|
|
|
const baseConfig = require('./webpack.base.js')
|
|
|
+const { name } = require('./package');
|
|
|
|
|
|
module.exports = WebpackMerge.merge(baseConfig, {
|
|
|
mode: 'production',
|
|
|
@@ -17,23 +18,48 @@ module.exports = WebpackMerge.merge(baseConfig, {
|
|
|
main: './src/main.js',
|
|
|
},
|
|
|
|
|
|
+
|
|
|
output: {
|
|
|
- path: path.resolve(__dirname, '../dist/dist/app'),
|
|
|
- publicPath: './dist/app/',
|
|
|
- filename: 'js/[name].[contenthash:8].js',
|
|
|
- chunkFilename: 'js/[name].[contenthash:8].js',
|
|
|
+ path: path.resolve(__dirname, './dist/client-trace-v3'),
|
|
|
+ publicPath: './',
|
|
|
+ library: `${name}`,
|
|
|
+ libraryTarget: 'umd', // 把微应用打包成 umd 库格式
|
|
|
+ filename: './asset-js-bundle/[name].[contenthash:8].js',
|
|
|
+ chunkFilename: './asset-js-chunk/[name].[contenthash:8].js',
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ optimization: {
|
|
|
+ minimize: true, // 压缩 bundle
|
|
|
+ splitChunks: {
|
|
|
+ // include all types of chunks
|
|
|
+ chunks: 'all',
|
|
|
+ // name: false,
|
|
|
+ minSize: 30000,
|
|
|
+ maxSize: 500000,
|
|
|
+ cacheGroups: {
|
|
|
+ common: {
|
|
|
+ test: /[\\/]node_modules[\\/]/,
|
|
|
+ name: 'common',
|
|
|
+ chunks: 'initial',
|
|
|
+ priority: 2,
|
|
|
+ minChunks: 2,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
+ //devtool: 'nosources-source-map', // 打包不需要 source-map
|
|
|
|
|
|
- devtool: 'source-map',
|
|
|
|
|
|
plugins: (module.exports.plugins || []).concat([
|
|
|
|
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
title: 'Prodog',
|
|
|
- template: './static/htmls/template.html', // 源模板文件
|
|
|
- filename: (process.env.NODE_ENV === 'production') ? '../../index.html' : './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
|
|
|
+ template: './public/index.html', // 源模板文件
|
|
|
+ filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
|
|
|
chunks: ['main']
|
|
|
}),
|
|
|
|
|
|
@@ -43,7 +69,7 @@ module.exports = WebpackMerge.merge(baseConfig, {
|
|
|
|
|
|
// CSS 提取
|
|
|
new MiniCssExtractPlugin({
|
|
|
- filename: "style/[name].[contenthash:8].css"
|
|
|
+ filename: "./asset-style/[name].[contenthash:8].css"
|
|
|
}),
|
|
|
|
|
|
])
|