const path = require('path')
const resolve = dir => {
return path.join(__dirname, dir)
}
const CopyWebpackPlugin = require('copy-webpack-plugin');
// 导入compression-webpack-plugin gzip 压缩
const CompressionPlugin = require('compression-webpack-plugin')
// 定义压缩文件类型
const productionGzipExtensions = ['js', 'css']
module.exports = {
publicPath: './',
outputDir: 'dist',
productionSourceMap: false,
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src'))
.set('@lib', resolve('src/common'))
.set('@com', resolve('src/components'))
.set('@view', resolve('src/views'))
.set('@img', resolve('src/images'))
.set('@style', resolve('src/common/scss'))
.set('@public', resolve('public'));
// 开启 gzip 压缩
// if (process.env.NODE_ENV === 'production') {
// config.plugin('compressionPlugin')
// .use(new CompressionPlugin({
// filename: '[path].gz[query]',
// algorithm: 'gzip',
// // test: productionGzipExtensions,
// test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
// threshold: 10240,
// minRatio: 0.8,
// deleteOriginalAssets: true
// }));
// }
// 图片压缩
// config.module.rule('images')
// .test(/\.(png|jpe?g|gif|svg)(\?.*)?$/)
// .use('file-loader')
// .loader('image-webpack-loader')
// .options({ bypassOnDebug: true })
},
devServer: {
open: true, // 是否自动打开浏览器页面
port: 10010, // 端口地址
https: false, // 使用https提供服务
// string | Object 代理设置
proxy: {
'/pic': {
target: 'http://124.160.79.186:8768',
changeOrigin: true,
pathRewrite: {
'^/pic': '/'
}
},
'/layer': {
target: 'http://10.1.20.153:10036/layer',
changeOrigin: true,
pathRewrite: {
'^/layer': ''
}
},
'/api': {
target: 'http://172.16.70.68:9050',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
},
'/v3': {
target: 'https://restapi.amap.com/v3',
changeOrigin: true,
pathRewrite: {
'^/v3': ''
}
},
'/ysx': {
target: 'http://10.1.20.153:9050',
changeOrigin: true,
pathRewrite: {
'^/ysx': ''
}
},
},
progress: true,
},
css: {
loaderOptions: {
sass: {
// @/ is an alias to src/
// so this assumes you have a file named `src/variables.scss`
data: `@import "src/common/scss/common.scss";`
}
}
}
};
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。