Browse Source

修改配置

master
yangzongjia 2 years ago
parent
commit
88622f506d
  1. 3
      .env.production
  2. 49
      vue.config.js

3
.env.production

@ -2,7 +2,8 @@
ENV = 'production' ENV = 'production'
# base api # base api
VUE_APP_BASE_API = '/monitorapi' # VUE_APP_BASE_API = '/monitorapi'
VUE_APP_BASE_API = '/api'
## 配置 正式接口地址 ## 配置 正式接口地址
VUE_APP_URL = "http://120.46.131.15:8111" VUE_APP_URL = "http://120.46.131.15:8111"

49
vue.config.js

@ -24,7 +24,8 @@ module.exports = {
*在大多数情况下请使用/ *在大多数情况下请使用/
*详细信息https://cli.vuejs.org/config/#publicpath *详细信息https://cli.vuejs.org/config/#publicpath
*/ */
publicPath: process.env.NODE_ENV === 'production' ? '/monitor/' : '/', // publicPath: process.env.NODE_ENV === 'production' ? '/monitor/' : '/',
publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
outputDir: 'monitor-ui', outputDir: 'monitor-ui',
assetsDir: 'static', assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development', lintOnSave: process.env.NODE_ENV === 'development',
@ -41,7 +42,7 @@ module.exports = {
proxy: { proxy: {
'/api': { // 匹配所有以 '/api'开头的请求路径 '/api': { // 匹配所有以 '/api'开头的请求路径
// target: 'http://192.168.1.109:8111', // target: 'http://192.168.1.109:8111',
target: process.env.VUE_APP_URL, // 代理目标的基础路径 target: process.env.VUE_APP_URL, // 代理目标的基础路径
changeOrigin: true, // 支持跨域 changeOrigin: true, // 支持跨域
pathRewrite: { // 重写路径: 去掉路径中开头的'/api' pathRewrite: { // 重写路径: 去掉路径中开头的'/api'
'^/api': '' '^/api': ''
@ -49,7 +50,7 @@ module.exports = {
}, },
'/upload': { // 匹配所有以 '/api'开头的请求路径 '/upload': { // 匹配所有以 '/api'开头的请求路径
// target: 'http://120.46.131.15:8111', // target: 'http://120.46.131.15:8111',
target: process.env.VUE_APP_URL, // 代理目标的基础路径 target: process.env.VUE_APP_URL, // 代理目标的基础路径
changeOrigin: true, // 支持跨域 changeOrigin: true, // 支持跨域
pathRewrite: { // 重写路径: 去掉路径中开头的'/api' pathRewrite: { // 重写路径: 去掉路径中开头的'/api'
'^/upload': '' '^/upload': ''
@ -112,28 +113,28 @@ module.exports = {
.end() .end()
config config
.optimization.splitChunks({ .optimization.splitChunks({
chunks: 'all', chunks: 'all',
cacheGroups: { cacheGroups: {
libs: { libs: {
name: 'chunk-libs', name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
priority: 10, priority: 10,
chunks: 'initial' // only package third parties that are initially dependent chunks: 'initial' // only package third parties that are initially dependent
}, },
elementUI: { elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package 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 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 test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
}, },
commons: { commons: {
name: 'chunk-commons', name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number minChunks: 3, // minimum common number
priority: 5, priority: 5,
reuseExistingChunk: true reuseExistingChunk: true
}
} }
} })
})
// https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
config.optimization.runtimeChunk('single') config.optimization.runtimeChunk('single')
} }

Loading…
Cancel
Save