63 lines
1.3 KiB
JavaScript
63 lines
1.3 KiB
JavaScript
const path = require('path')
|
||
|
||
module.exports = {
|
||
publicPath: './',
|
||
lintOnSave: false,
|
||
productionSourceMap: false,
|
||
devServer: {
|
||
hot: true,
|
||
hotOnly: true,
|
||
host: '0.0.0.0',
|
||
port: 9090,
|
||
compress: true,
|
||
open: true,
|
||
openPage: '#/',
|
||
overlay: {
|
||
warnings: true,
|
||
errors: true,
|
||
},
|
||
proxy: {
|
||
'/api': {
|
||
target: 'http://115.159.153.142:9010/',
|
||
changeOrigin: true,
|
||
ws: true,
|
||
pathRewrite: {
|
||
'^/api': ''
|
||
}
|
||
}
|
||
}
|
||
},
|
||
chainWebpack: config => {
|
||
|
||
// 去除 preload 和 prefetch,减少页面请求次数
|
||
config.plugins.delete('preload')
|
||
config.plugins.delete('prefetch')
|
||
|
||
// 配置路径别名
|
||
config.resolve.alias
|
||
.set('@', resolve('src'))
|
||
.set('!', resolve('src/assets/styl/page'))
|
||
|
||
// 配置css的全局自动导入
|
||
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
|
||
types.forEach(type => addStyleResource(config.module.rule('stylus').oneOf(type)))
|
||
},
|
||
|
||
};
|
||
|
||
|
||
function addStyleResource (rule) {
|
||
rule.use('style-resource')
|
||
.loader('style-resources-loader')
|
||
.options({
|
||
patterns: [
|
||
path.resolve(__dirname, './src/assets/styl/imports.styl'),
|
||
],
|
||
})
|
||
}
|
||
|
||
|
||
function resolve (dir) {
|
||
return path.join(__dirname, dir)
|
||
}
|