修改配置

cyl/dev
Matripe 3 years ago
parent 87e4180ccf
commit b19c541303

@ -1,8 +1,8 @@
"use strict";
const path = require("path");
const defaultSettings = require("./src/settings.js");
// const webpack = require("webpack");
// const CompressionPlugin = require("compression-webpack-plugin");
const webpack = require("webpack");
const CompressionPlugin = require("compression-webpack-plugin");
// const zlib = require("zlib");
function resolve(dir) {
return path.join(__dirname, dir);
@ -21,6 +21,7 @@ module.exports = {
productionSourceMap: false,
devServer: {
// 配置反向代理
compress: true, // 配置webpack的压缩,但是在package.json中需要配置 --compress
port: port,
open: true,
overlay: {
@ -31,9 +32,9 @@ module.exports = {
// 地址中有 /api 的时候会触发代理
"/api_prod": {
// target: "http://localhost:8001/",
target: "http://bl7.matripe.com.cn:8001",
// target: "http://bl7.matripe.com.cn:8001",
// target: "http://1shoudan.renminshitang.com.cn",
// target: "https://d.matripe.com.cn",
target: "https://d.matripe.com.cn",
ws: true, // proxy websockets
changeOrigin: true, // 确定是否跨域
pathRewrite: {
@ -92,20 +93,20 @@ module.exports = {
"@ant-design/icons/lib/dist.$": resolve("src/icons.js"),
},
},
// plugins: [
plugins: [
// new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// // 下面两项配置才是 compression-webpack-plugin 压缩配置
// // 压缩成 .gz 文件
// new CompressionPlugin({
// filename: '[path][base].gz',
// algorithm: 'gzip',
// test: /\.js$|\.css$|\.html$/,
// algorithm: "gzip",
// test: /\.js$|\.html$|\.css/, //匹配文件名
// threshold: 10240,
// minRatio: 0.8
// minRatio: 0.8,
// deleteOriginalAssets: false, // 是否删除源文件
// }),
// // 压缩成 .br 文件,如果 zlib 报错无法解决,可以注释这段使用代码,一般本地没问题,需要注意线上服务器会可能发生找不到 zlib 的情况。
// 压缩成 .br 文件,如果 zlib 报错无法解决,可以注释这段使用代码,一般本地没问题,需要注意线上服务器会可能发生找不到 zlib 的情况。
// new CompressionPlugin({
// filename: '[path][base].br',
// filename: '[path].br',
// algorithm: 'brotliCompress',
// test: /\.(js|css|html|svg)$/,
// compressionOptions: {
@ -114,9 +115,10 @@ module.exports = {
// }
// },
// threshold: 10240,
// minRatio: 0.8
// minRatio: 0.8,
// deleteOriginalAssets: true //是否删除原文件
// })
// ],
],
// },
optimization: {
runtimeChunk: "single",

Loading…
Cancel
Save