| | |
| | | 'use strict' |
| | | const path = require('path') |
| | | const defaultSettings = require('./src/settings.js') |
| | | const webpack = require('webpack') |
| | | |
| | | function resolve(dir) { |
| | | return path.join(__dirname, dir) |
| | |
| | | outputDir: 'dist', |
| | | assetsDir: 'static', |
| | | lintOnSave: process.env.NODE_ENV === 'development', |
| | | // css: { |
| | | // loaderOptions: { |
| | | // css: {}, |
| | | // postcss: { |
| | | // plugins: [ |
| | | // require('postcss-px2rem')({ |
| | | // remUnit: 192// /设计图宽度/10 |
| | | // }) |
| | | // ] |
| | | // } |
| | | // } |
| | | // }, |
| | | transpileDependencies: ['screenfull'], |
| | | productionSourceMap: false, |
| | | devServer: { |
| | | port: port, |
| | |
| | | }, |
| | | proxy: { |
| | | [process.env.VUE_APP_BASE_API]: { |
| | | target: process.env.VUE_APP_BASE_API, // 请求的第三⽅接⼝地址 |
| | | changeOrigin: true, // 请求跨域时,需配置此项 |
| | | target: 'http://121.196.36.24:8001', // 请求的第三⽅接⼝地址 本地开发服务器 |
| | | // target: 'http://192.168.2.138:8001', // 请求的第三⽅接⼝地址 客户服务器(大岛) |
| | | // target: 'http://192.168.5.176:8001', // 请求的第三⽅接⼝地址 客户服务器(普登) |
| | | changeOrigin: true, // 请求跨域时,需 配置此项 |
| | | pathRewrite: { // 路径重写,替换target中的请求地址 |
| | | ['^' + process.env.VUE_APP_BASE_API]: '' |
| | | ['^' + process.env.VUE_APP_BASE_API]: '/api/' |
| | | } |
| | | // ws: true;//开启ws, 如果是http代理此处可以不用设置 |
| | | } |
| | | } |
| | | // before: require('./mock/mock-server.js') |
| | |
| | | alias: { |
| | | '@': resolve('src') |
| | | } |
| | | } |
| | | }, |
| | | plugins: [ |
| | | new webpack.ProvidePlugin({ |
| | | jQuery: 'jquery', |
| | | $: 'jquery' |
| | | }) |
| | | ], |
| | | // module: { |
| | | // rules: [ |
| | | // { |
| | | // test: /.vue$/, |
| | | // loader: 'vue-loader' |
| | | // } |
| | | // ] |
| | | // } |
| | | }, |
| | | chainWebpack(config) { |
| | | // it can improve the speed of the first screen, it is recommended to turn on preload |
| | |
| | | .plugin('ScriptExtHtmlWebpackPlugin') |
| | | .after('html') |
| | | .use('script-ext-html-webpack-plugin', [{ |
| | | // `runtime` must same as runtimeChunk name. default is `runtime` |
| | | // `runtime` must same as runtimeChunk name. default is `runtime` |
| | | inline: /runtime\..*\.js$/ |
| | | }]) |
| | | .end() |
| | | config |
| | | .optimization.splitChunks({ |
| | | chunks: 'all', |
| | | cacheGroups: { |
| | | libs: { |
| | | name: 'chunk-libs', |
| | | test: /[\\/]node_modules[\\/]/, |
| | | priority: 10, |
| | | chunks: 'initial' // only package third parties that are initially dependent |
| | | }, |
| | | elementUI: { |
| | | name: 'chunk-elementUI', // split elementUI into a single package |
| | | priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app |
| | | test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm |
| | | }, |
| | | commons: { |
| | | name: 'chunk-commons', |
| | | test: resolve('src/components'), // can customize your rules |
| | | minChunks: 3, // minimum common number |
| | | priority: 5, |
| | | reuseExistingChunk: true |
| | | } |
| | | chunks: 'all', |
| | | cacheGroups: { |
| | | libs: { |
| | | name: 'chunk-libs', |
| | | test: /[\\/]node_modules[\\/]/, |
| | | priority: 10, |
| | | chunks: 'initial' // only package third parties that are initially dependent |
| | | }, |
| | | elementUI: { |
| | | name: 'chunk-elementUI', // split elementUI into a single package |
| | | priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app |
| | | test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm |
| | | }, |
| | | commons: { |
| | | name: 'chunk-commons', |
| | | test: resolve('src/components'), // can customize your rules |
| | | minChunks: 3, // minimum common number |
| | | priority: 5, |
| | | reuseExistingChunk: true |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk |
| | | config.optimization.runtimeChunk('single') |
| | | } |