webpack从2.0升级到3.0后,打包报错webpack 3 DeprecationWarning: Chunk.modules is deprecated

项目webpack版本一直是2.6.0,想升级到3后,提升一下打包速度,升级之后发现打包报错:
DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead

原因是因为,extract-text-webpack-plugin 这个插件不推荐使用chunk.modules了,确定了是版本问题

解决方法:webpack升级到3.8.1,npm install [email protected] --save-dev
extract-text-webpack-plugin升级到3.0.2,[email protected] --save-dev

我的package.json文件

{
  "name": "AG-Admin",
  "version": "1.2.0",
  "description": "A Vue.js admin",
  "author": "Ace<[email protected]>",
  "license": "MIT",
  "private": true,
  "scripts": {
    "dev": "node build/dev-server.js",
    "build:prod": "cross-env NODE_ENV=production node build/build.js",
    "build:sit": "cross-env NODE_ENV=sit node build/build.js",
    "build:sit-preview": "cross-env NODE_ENV=sit npm_config_preview=true  npm_config_report=true node build/build.js",
    "lint": "eslint --ext .js,.vue src"
  },
  "dependencies": {
    "@antv/g6": "3.0.4",
    "@fortawesome/fontawesome": "^1.1.8",
    "@fortawesome/fontawesome-free-brands": "^5.0.13",
    "@fortawesome/fontawesome-free-regular": "^5.0.13",
    "@fortawesome/fontawesome-free-solid": "^5.0.13",
    "@fortawesome/fontawesome-svg-core": "^1.2.15",
    "@fortawesome/vue-fontawesome": "^0.1.5",
    "axios": "0.16.2",
    "babel-polyfill": "^6.26.0",
    "codemirror": "5.26.0",
    "compression-webpack-plugin": "1.1.12",
    "crypto": "^1.0.1",
    "crypto-js": "^3.1.9-1",
    "dayjs": "^1.8.28",
    "dropzone": "5.1.0",
    "echarts": "3.6.2",
    "echarts-wordcloud": "1.1.0",
    "element-ui": "^2.12.0",
    "file-saver": "1.3.3",
    "html2canvas": "1.0.0-alpha.12",
    "jquery": "3.1.1",
    "js-cookie": "2.1.4",
    "js-sha256": "^0.9.0",
    "jsonlint": "1.6.2",
    "jszip": "^3.1.5",
    "lib-flexible": "^0.3.2",
    "mockjs": "1.0.1-beta3",
    "normalize.css": "3.0.2",
    "nprogress": "0.2.0",
    "px2rem-loader": "^0.1.9",
    "screenfull": "3.2.2",
    "showdown": "1.7.1",
    "simplemde": "1.11.2",
    "sortablejs": "1.5.1",
    "vue": "2.6.6",
    "vue-contextmenu": "1.4.8",
    "vue-count-to": "1.0.5",
    "vue-cron": "^1.0.9",
    "vue-grid-layout": "^2.3.3",
    "vue-multiselect": "2.0.0-beta.15",
    "vue-router": "2.5.3",
    "vue-tooltip-v": "0.0.5",
    "vuedraggable": "2.13.1",
    "vuex": "2.3.1",
    "xlsx": "^0.10.8"
  },
  "devDependencies": {
    "autoprefixer": "7.1.1",
    "babel-core": "6.25.0",
    "babel-eslint": "7.2.3",
    "babel-loader": "7.0.0",
    "babel-plugin-transform-runtime": "6.23.0",
    "babel-preset-env": "1.5.2",
    "babel-preset-stage-2": "6.24.1",
    "babel-register": "6.24.1",
    "chalk": "1.1.3",
    "connect-history-api-fallback": "1.3.0",
    "copy-webpack-plugin": "4.0.1",
    "cross-env": "5.0.1",
    "css-loader": "0.28.4",
    "element-resize-detector": "^1.1.15",
    "eslint": "^3.19.0",
    "eslint-friendly-formatter": "3.0.0",
    "eslint-import-resolver-webpack": "0.8.1",
    "eslint-loader": "1.7.1",
    "eslint-plugin-html": "3.0.0",
    "eslint-plugin-import": "2.3.0",
    "eventsource-polyfill": "0.9.6",
    "express": "4.15.3",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "0.11.2",
    "friendly-errors-webpack-plugin": "1.6.1",
    "function-bind": "1.1.0",
    "html-webpack-plugin": "2.28.0",
    "http-proxy-middleware": "0.17.4",
    "node-sass": "4.12.0",
    "opn": "4.0.2",
    "optimize-css-assets-webpack-plugin": "1.3.0",
    "ora": "1.1.0",
    "pushstate-server": "2.1.0",
    "rimraf": "2.6.0",
    "sass-loader": "6.0.5",
    "script-loader": "0.7.0",
    "semver": "5.3.0",
    "style-loader": "0.17.0",
    "terser-webpack-plugin": "^3.0.6",
    "url-loader": "0.5.8",
    "vue-loader": "12.2.1",
    "vue-style-loader": "3.0.1",
    "vue-template-compiler": "2.6.6",
    "webpack": "3.8.1",
    "webpack-bundle-analyzer": "2.8.2",
    "webpack-dev-middleware": "1.10.2",
    "webpack-hot-middleware": "2.18.0",
    "webpack-merge": "4.1.0"
  },
  "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

你可能感兴趣的:(webpack从2.0升级到3.0后,打包报错webpack 3 DeprecationWarning: Chunk.modules is deprecated)