Nuxt.js 引入的JS文件大于500KB导致BABEL报错

如题,run dev 报错:

[BABEL] Note: The code generator has deoptimised the styling of XXX.js as it exceeds the max of 500KB.

百度过 都是在根目录新建.babelrc文件然后配置"compact": false,但是在nuxt下无效,请问如何解决?(我引如的这个JS文件有7000KB)

以下是我的 package.json

{
  "name": "nuxtdmo",
 "version": "1.0.0",
 "private": true,
 "scripts": {
     "dev": "cross-env BASE_URL=http://localhost:8180 NODE_ENV=development nuxt",
     "build:test": "cross-env BASE_URL=http://localhost:2001/api NODE_ENV=test nuxt build",
     "start:test": "cross-env BASE_URL=http://localhost:2001/api NODE_ENV=test nuxt start",
     "build:pro": "cross-env BASE_URL=http://localhost:2001/api NODE_ENV=production nuxt build",
     "start:pro": "cross-env BASE_URL=http://localhost:2001/api NODE_ENV=production nuxt start",
     "generate": "nuxt generate",
     "lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .",
     "lint": "npm run lint:js"
 },
 "dependencies": {
     "@nuxtjs/axios": "^5.12.2",
     "core-js": "^3.6.5",
     "element-ui": "^2.13.2",
     "nuxt": "^2.14.5"
 },
 "devDependencies": {
     "@nuxtjs/eslint-config": "^3.1.0",
     "@nuxtjs/eslint-module": "^2.0.0",
     "babel-eslint": "^10.1.0",
     "cross-env": "^7.0.2",
     "eslint": "^7.8.1",
     "eslint-plugin-nuxt": "^1.0.0",
     "less": "^3.12.2",
     "less-loader": "^7.0.1"
 }
}
阅读 7.2k
1 个回答

nuxt.config.js文件里面

module.exports = {
   build: {
         babel: {
            compact: false
         }
   }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题