Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
660 views
in Technique[技术] by (71.8m points)

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"
 }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

nuxt.config.js文件里面

module.exports = {
   build: {
         babel: {
            compact: false
         }
   }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...