zszq-celebration-88/vue.config.js
2022-07-26 18:26:27 +08:00

112 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const path = require('path');
const resolve = (dir) => path.join(__dirname, '.', dir);
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const isProduction = process.env.NODE_ENV === 'production'
const IS_PROD = ["production", "prod"].includes(process.env.NODE_ENV);
const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i;
const CompressionWebpackPlugin = require("compression-webpack-plugin");
module.exports = {
// 多页面配置
pages: {
index: {
entry: 'src/page/Home/main.js',
template: 'public/index.html',
filename: 'index.html',
title: '招商证券88司庆活动',
},
share: {
entry: 'src/page/Share/main.js',
template: 'public/share.html',
filename: 'share.html',
title: '分享页',
}
},
// 打包路径配置
productionSourceMap: false,
publicPath: process.env.NODE_ENV == "production" ? process.env.VUE_APP_CDN : './', // CDN路径
// publicPath: process.env.VUE_APP_CDN, // CDN路径
outputDir: 'dist', //打包后生成的目录名称
assetsDir: 'static', //静态资源名称
indexPath: 'index.html', //html的输出路径
// css相关配置
css: {
// 引入scss公共样式
loaderOptions: {
sass: {
data: `@import "@/assets/style/global.scss";`
}
},
extract: true // 是否使用css分离插件 ExtractTextPlugin
},
// filenameHashing: false, //去掉打包后的hash值
// 开启gzip压缩
configureWebpack: config => {
const plugins = [];
if (IS_PROD) {
plugins.push(
new CompressionWebpackPlugin({
filename: "[path].gz[query]",
algorithm: "gzip",
test: productionGzipExtensions,
threshold: 10240,
minRatio: 0.8
})
);
}
config.plugins = [...config.plugins, ...plugins];
},
chainWebpack: config => {
// 别名配置
config.resolve.alias
.set("@", resolve("src"))
.set("@assets", resolve("src/assets"))
.set("@views", resolve("src/views"))
// 标题配置
// config
// .plugin('html')
// .tap(args => {
// args[0].title = '双优精英'
// return args
// })
// babel-polyfill配置
config.entry('main').add('babel-polyfill')
devtool: 'inline-source-map'
},
// 关闭eslint校验
lintOnSave: false,
devServer: {
overlay: {
warning: false,
errors: false
},
// proxy: {
// // wss跨域配置
// '/wsq': {
// //需要访问的服务器地址
// target: 'wss://h5.qiween.cn/jlg520/websocket',
// //后面空格替换前面,确保服务器有这个地址
// pathRewrite: { '^/wsq': '' },
// //false时以原域名访问服务器true时原域名变成服务器域名访问
// changeOrigin: true
// }
// }
},
productionSourceMap: false, // 生产环境是否生成 sourceMap 文件
};