You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.4 KiB

10 months ago
/**
* 配置参考: https://cli.vuejs.org/zh/config/
*/
'use strict'
const path = require('path')
// const defaultSettings = require('./src/settings.js')
const CopyPlugin = require('copy-webpack-plugin')
3 months ago
const CompressionPlugin = require('compression-webpack-plugin');
10 months ago
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
parallel: false,
publicPath: '/', // 其他正式环境
3 months ago
// publicPath: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_HOUZHUI : '/', //公司内部环境打开
10 months ago
assetsDir: 'static',
chainWebpack: config => {
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.test(/\.svg$/)
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
},
// 默认打开eslint效验,如果需要关闭,设置成false即可
lintOnSave: false,
runtimeCompiler: true,
productionSourceMap: false,
devServer: {
open: true,
hot: true,
port: 8002,
host: '127.0.0.1',
overlay: {
errors: true,
warnings: true
},
// proxy: {
// // 配置跨域
// '/proxy_url': {
// target: 'http://192.168.188.55:30029', // 这里后台的地址模拟的;应该填写真实的后台接口
// changOrigin: true, // 允许跨域
// pathRewrite: { // 路径重写
// '^/proxy_url': '' // 替换target中的请求地址,原请求为 http://127.0.0.1:8000/kuayu 实际请求为 http://127.0.0.1:8000/proxy_url/kuayu
// }
// }
// }
proxy: {
// 反向代理
'/customProxyCa': {
target: 'https://ca.wzeye.cn',
changOrigin: true, // 允许跨域
pathRewrite: { // 路径重写
'^/customProxyCa': '/'
}
},
// 反向代理
7 months ago
'/hz_quguang': {
10 months ago
target: process.env.VUE_APP_LOGIN_URL, // 想请求的目标地址
changOrigin: true, // 允许跨域
pathRewrite: { // 路径重写
7 months ago
'^/hz_quguang': '/hz_quguang'
10 months ago
}
5 months ago
},
// '/ollama': {
// target: 'http://localhost:11434',
// changOrigin: true, // 允许跨域
// pathRewrite: {
// '^/ollama': ''
// },
// }
10 months ago
}
},
configureWebpack: {
3 months ago
optimization: {
splitChunks: {
chunks: 'all', // 所有模块都参与分割
cacheGroups: {
vendors: {
name: 'chunk-vendors',
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'initial'
},
common: {
name: 'chunk-common',
minChunks: 2,
priority: -20,
chunks: 'initial',
reuseExistingChunk: true
}
}
}
},
10 months ago
resolve: {
alias: {
'vue': 'vue/dist/vue.esm.js',
'@': resolve('src'),
'@static': path.resolve(__dirname, 'static')
}
},
plugins: [
// new CopyPlugin([
// { from: path.resolve(__dirname, './static'), to: 'static' }
// ])
3 months ago
new CopyPlugin({
patterns: [
{ from: path.resolve(__dirname, 'static'), to: 'static' }
]
}),
2 months ago
// new CompressionPlugin({
// test: /\.(js|css|html|svg)$/, // 压缩类型
// threshold: 10240, // 超过 10kb 的文件才压缩
// minRatio: 0.8, // 压缩比大于 0.8 才压缩
// algorithm: 'gzip',
// deleteOriginalAssets: false // 保留源文件
// })
10 months ago
],
// externals: {
// 'pdfjs-dist': 'pdfjsLib'
// }
},
// rem适配
// css: {
// loaderOptions: {
// postcss: {
// plugins: [
// require('postcss-plugin-px2rem')({
// rootValue: 50, // 换算基数, 默认100 ,这样的话把根标签的字体规定为1rem为50px,这样就可以从设计稿上量出多少个px直接在代码中写多上px了。
// exclude: /node_modules/i,
// mediaQuery: false, // (布尔值)允许在媒体查询中转换px。
// minPixelValue: 3 // 设置要替换的最小像素值(3px会被转rem)。 默认 0
// })
// ]
// }
// }
// },
pages: {
index: {
template: 'public/index.html',
entry: 'src/page-subspecialty/main.js',
filename: 'index.html',
title: 'index'
}
// project: {
// template: 'public/project.html',
// entry: 'src/page-project/main.js',
// filename: 'project.html',
// title: 'project'
// }
}
}