記一次npm run build報錯問題


npm run dev沒毛病,但npm run build

報錯如下:

> node build/build.js

⠦ building for production...Error processing file: static/css/app.2b5a4ab0a175fecacbed4269c2349cf3.css
(node:51504) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Object.entries is not a function

解決辦法:
1、把webpack.prod.conf.js css代碼壓縮關掉

 

 

2、在urils.js 壓縮

 

 

 

 

追加一個npm run build時遇到的報錯:

RROR in static/js/vendor.e233ca09723089181958.js from UglifyJs
Unexpected token: operator (>) [./~/is-blob/index.js:3,0][static/js/vendor.e233ca09723089181958.js:100261,24]

 

 

解決辦法:

build/webpack.prod.conf.js文件里的這一段代碼注釋掉
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: false
// },
// sourceMap: true
// }),

 

在成功編譯之后,將生成的dist目錄由nginx代理之后,請求頁面,遇到問題:Uncaught SyntaxError: Unexpected token '<'

解決辦法:

config/index.js里的build 參數assetsPublicPath 由vue-admin改為/

  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'],
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  },

 


免責聲明!

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



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