Authored by huangyi

优化结构

import webpack, {DefinePlugin} from 'webpack';
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
import path from 'path';
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import CleanWebpackPlugin from 'clean-webpack-plugin';
import HtmlWebpackPlugin from "html-webpack-plugin";
import config from "./config";
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
let pathsToClean = [
'dist'
... ... @@ -24,6 +26,8 @@ let baseArr = [
chunkFilename: "css/[id].css"
}),//css分离
new CleanWebpackPlugin(pathsToClean, cleanOptions),//清除历史版本
new UglifyJsPlugin({test: /\.js($|\?)/i,parallel: false})
];
let htmls = function () {
const title = require('./app/' + config.currentApp + '/title');
... ... @@ -46,6 +50,16 @@ let htmls = function () {
};
module.exports = {
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true // set to true if you want JS source maps
}),
new OptimizeCSSAssetsPlugin({})
]
},
//项目入口js文件
entry: [`./app/${config.currentApp}/index.js`],
//项目输出目录
... ...