问题:vue 项目打包后访问不到页面
报错Failed to load resource: the server responded with a status of 404 (Not Found)
原因:没有暴露静态资源
解决:
在项目的根目录下创建一个vue-config.js文件。
代码如下:
const path = require(‘path’)
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
//路径根据自己的情况定,默认就填"./",静态资源的路径在static文件夹下就写’./static’
publicPath: ‘./static’,
//配置服务器,自动打开页面
devServer: {
open: true
},
configureWebpack: {
resolve: {
alias: {
‘@’: resolve(‘src’)
}
}
}
}