1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- const path = require('path');
- const CompressionPlugin = require('compression-webpack-plugin');
- module.exports = {
- publicPath: `/${process.env.VUE_APP_ROUTER}`,
- // 打包文件
- outputDir: `${process.env.VUE_APP_ROUTER}`,
- productionSourceMap: false,
- configureWebpack: (config) => {
- Object.assign(config, {
- // 开发生产共同配置
- resolve: {
- extensions: ['.js', '.json', '.vue'],
- alias: {
- '@': path.resolve(__dirname, './src'),
- '@c': path.resolve(__dirname, './src/components'),
- '@a': path.resolve(__dirname, './src/assets'),
- },
- },
- });
- if (process.env.NODE_ENV === 'production') {
- //生产环境
- config.plugins.push(
- new CompressionPlugin({
- /* [file]被替换为原始资产文件名。
- [path]替换为原始资产的路径。
- [dir]替换为原始资产的目录。
- [name]被替换为原始资产的文件名。
- [ext]替换为原始资产的扩展名。
- [query]被查询替换。*/
- filename: '[path].gz[query]',
- //压缩算法
- algorithm: 'gzip',
- //匹配文件
- test: /\.js$|\.css$|\.html$/,
- //压缩超过此大小的文件,以字节为单位
- threshold: 10240,
- minRatio: 0.8,
- //删除原始文件只保留压缩后的文件
- //deleteOriginalAssets: false
- })
- );
- config.externals = {
- vue: 'Vue',
- 'vue-router': 'VueRouter',
- vuex: 'Vuex',
- axios: 'axios',
- moment: 'moment',
- lodash: '_',
- vant: 'vant',
- };
- }
- },
- devServer: {
- port: '9801',
- //api地址前缀
- proxy: {
- '/files': {
- target: 'http://broadcast.waityou24.cn',
- },
- '/wxgateway': {
- target: 'http://broadcast.waityou24.cn', //http://192.168.1.19:9101
- changeOrigin: true,
- ws: false,
- },
- '/api': {
- target: 'http://192.168.1.19:11001', //http://192.168.1.19:9101
- changeOrigin: true,
- ws: false,
- },
- },
- },
- };
|