1 Star 0 Fork 0

dhu431/前端-React

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.prod.config.js 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
尘落 提交于 2022-02-08 19:54 . react17.0.2
const webpack = require('webpack');
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const path = require('path');
const fs = require('fs');
const md5 = require('md5');
const BabiliPlugin = require('babili-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
function readFileContent(match) {
return fs.readFileSync(match);
}
module.exports = {
devtool: 'source-map',
entry: {
org: [
'babel-polyfill',
'./script/org.app.js',
],
mobile: [
'babel-polyfill',
'./script/mobile.app.js',
],
},
output: {
path: path.resolve(__dirname, 'www'),
filename: '[name].bundle.js',
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(true), // 该插件在2.0版本已经默认启用并且重命名
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new UglifyJsPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// sourceMap: false,
// minimize: true,
// compress: {
// warnings: true,
// },
// }),
new ReplaceInFileWebpackPlugin([{
dir: './',
test: /\.bundle\.js$/,
rules: [{
search: /\/images\/((?!:).){0,30}\.(jpe?g|png|gif|svg)/g,
replace: function (match) {
return match + '?' + md5(readFileContent(__dirname + '/www' + match));
},
}],
}]),
],
module: {
rules: [
{
test: /\.js$/,
use: [{ loader: 'babel-loader' }],
exclude: /node_modules/,
},
{
test: /\.scss$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'sass-loader', options: { sourceMap: true } },
],
},
{
test: /\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
},
],
},
devServer: {
progress: true,
colors: true,
contentBase: './www',
port: 3001,
host: '0.0.0.0',
},
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dhu431/React.git
git@gitee.com:dhu431/React.git
dhu431
React
前端-React
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385