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.

104 lines
2.7 KiB

/**
* 配置参考: https://cli.vuejs.org/zh/config/
*/
'use strict'
const path = require('path')
// const defaultSettings = require('./src/settings.js')
const CopyPlugin = require('copy-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
parallel: false,
publicPath: '/', // 多页面情况 process.env.NODE_ENV === 'production' ? './' : '/',
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: 8022,
host: '127.0.0.1',
overlay: {
errors: true,
warnings: true
},
// proxy: { // 配置跨域
// '/huimu-admin': {
// target: 'http://192.168.3.107:8081/huimu-admin', // 这里后台的地址模拟的;应该填写真实的后台接口
// changOrigin: true // 允许跨域
// }
// }
proxy: {
// 反向代理
'/quguang': {
target: process.env.VUE_APP_LOGIN_URL, // 想请求的目标地址
changOrigin: true, // 允许跨域
pathRewrite: { // 路径重写
'^/quguang': '/quguang'
}
}
}
},
configureWebpack: {
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' }
// ])
new CopyPlugin({ patterns: [
{ from: path.resolve(__dirname, 'static'), to: 'static' }
] })
]
},
// rem适配
css: {
loaderOptions: {
postcss: {
plugins: [
require('postcss-plugin-px2rem')({
rootValue: 37.5, // 换算基数, 默认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'
// }
}
}