VUE-CLI webpack 项目打包部署上线

很简单不复杂只须要几步
一、找到项目的 webpack环境配置的config目录下的index.js文件的assetsPublicPath把"/"改为 "./"
得出: build: {
env: require('./prod.env'),
index: path.resolve(dirname, '../dist/index.html'),
assetsRoot: path.resolve(
dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',//这个就是刚刚修改的
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to true, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css']
....
}
二、找到biuld目录下的utils文件修改为 publicPath:'../../'
三、修改路由router目录下的文件
router = new VueRoter({
mode: 'history',
base: '/aaa/', //aaa 就是服务器Tomact相对于根目录的名称 在此目录放的就是 static 和 index.html文件 这两文件你是项目打包生成的dist文件只要copy过来就能成功部署在服务器上进行访问了
routes:[{
path:'./',
name:'',
component:'''
....省略
}]
)}css

相关文章
相关标签/搜索