1 Star 2 Fork 0

a07061625 / nk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.production.js 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
紫血剑神 提交于 2022-05-03 10:02 . init
//速度分析
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const smp = new SpeedMeasurePlugin();
const glob = require('glob');
const path = require('path');
const fs = require('fs');
const PurgeCSSPlugin = require('purgecss-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const AddAssetHtmlWebpackPlugin = require('add-asset-html-webpack-plugin');
const webpack = require('webpack');
let productConfig = require('./webpack.base');
productConfig.mode = 'production';
productConfig.output = {
path: path.resolve(__dirname, './dist'),
filename: 'js/[name].[contenthash:8].js',
chunkFilename: 'js/[name].[contenthash:8].chunk.js',
publicPath: 'http://120.79.139.64:8800/'
};
// 消除未使用的CSS
productConfig.plugins.push(new PurgeCSSPlugin({
paths: glob.sync('./views/*/*.html')
}));
// 压缩CSS
productConfig.plugins.push(new MiniCssExtractPlugin({
filename: 'css/[name].[chunkhash:8].css',
chunkFilename: 'css/[id].css'
}));
const files = fs.readdirSync(path.resolve(__dirname, './dll'));
files.forEach(file => {
if(/.*\.dll.js/.test(file)) {
productConfig.plugins.push(new AddAssetHtmlWebpackPlugin({
filepath: path.resolve(__dirname, './dll', file)
}));
}
if(/.*\.manifest.json/.test(file)) {
productConfig.plugins.push(new webpack.DllReferencePlugin({
manifest: path.resolve(__dirname, './dll', file)
}));
}
});
module.exports = smp.wrap(productConfig);
NodeJS
1
https://gitee.com/a07061625/nk.git
git@gitee.com:a07061625/nk.git
a07061625
nk
nk
master

搜索帮助