在vue.config.js文件里面
'user strict'
const path = require('path')
const defaultSettings = require('./src/settings.js') // title的配置文件
function resolve(dir) {
return path.join(__dirname, dir)
}
const name = defaultSettings.title || 'title' // page title
const port = process.env.port || process.env.npm_config_port || 9888
module.exports = {
publicPath: '/', // 部署应用包时的基本 URL
assetsDir: 'static', // 放置生成的静态资源的目录
productionSourceMap: false, // 如果你不需要生产环境的 source map
devServer: {
port, // 端口
open: true, // 启动后默认打开浏览器
// 出现编译器错误或警告时,在浏览器中显示全屏覆盖。
overlay: {
warnings: true,
errors: true
},
proxy: {
'/dev-api': {
target: 'http://192.xxx.xxx',
changeOrigin: true, // 允许websockets跨域
// ws: true,
pathRewrite: {
'^/dev-api': ''
}
}
} // 代理转发配置,用于调试环境
},
configureWebpack: {
// 在webpack的name字段中提供应用程序的标题,以便
// 它可以在索引.html插入正确的标题
name: name,
resolve: {
alias: { // 路径别名设置
'@': resolve('src')
}
}
}
}