2 Star 0 Fork 0

dior206/hotel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue.config.js 3.33 KB
一键复制 编辑 原始数据 按行查看 历史
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
const isProduction = process.env.NODE_ENV === 'production'
const webpack = require('webpack');
const path = require('path');
module.exports = {
publicPath: './',
// assetsPublicPath: "/",
//禁用eslint检查
lintOnSave: false,
outputDir: "develop",
publicPath: '/develop/',
productionSourceMap: false,
//代理服务器设置解决跨域的问题
devServer: {
//防止代理服务器,访问时显示:Invalid Host header
disableHostCheck: true,
open: true,
port: 80,
proxy: {
//新增一个服务器需要配置一个转发地址
'/api/server2': {
target: 'https://server2.cdkjcloud.com',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api/server2': ''
}
},
'/ping': {
target: 'https://server2.cdkjcloud.com',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/ping': ''
}
},
'/wx': {
target: 'https://api.weixin.qq.com',
changeOrigin: true,
ws: true,
pathRewrite: {
'^/wx': ''
}
},
}
},
configureWebpack: config => {
// 公共代码抽离
config.optimization = {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'all',
test: /node_modules/,
name: 'vendor',
minChunks: 1,
maxInitialRequests: 5,
minSize: 0,
priority: 100
}
}
}
}
},
configureWebpack:{
// devtool: '#eval-source-map',
resolve:{
alias:{
'@':path.resolve(__dirname, './src'),
'@i':path.resolve(__dirname, './src/assets'),
}
},
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// 配置compression-webpack-plugin压缩
new CompressionWebpackPlugin({
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 5,
minChunkSize: 100
})
]
},
chainWebpack: config => {
// 精简js文件
config.optimization.minimize(true);
// 移除多余插件,避免加载多余资源
config.plugins.delete('prefetch');
},
css: {
loaderOptions: {
css: {
// options here will be passed to css-loader
},
postcss: {
// options here will be passed to postcss-loader
plugins:[require('postcss-px2rem')({
remUnit: 37.5 //要除以2因为是2倍图,除以2因为第三方插件是1倍的,这里是设计稿的尺寸是750px
})]
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/dior206/hotel.git
git@gitee.com:dior206/hotel.git
dior206
hotel
hotel
master

搜索帮助