vue項目打包部署生產環境


打包部署生產環境之前需要修改配置文件:

修改一:build > utils.js  (修改publicPath:"../../" , 這樣寫是處理打包后找不到靜態文件的問題)

 

// Extract CSS when that option is specified
    // (which is the case during production build)
    if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader',
        publicPath: '../../'
      })
    } else {
      return ['vue-style-loader'].concat(loaders)
    }

 

 

 

 

修改二:config > index.js (修改assetsPublicPath:'./' ,修改目的是為了解決js找不到的問題)

 // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',

 

 

 3.運行命令:npm run build 打包直接訪問dist文件夾中的index.html即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM