webpack使用extract-text-webpack-plugin 提示Use Chunks.groupsIterable and filter by instanceof Entrypoint

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dz45693/article/details/82865428

前提条件:
当前时间是2018年9月27日。
webpack的最新版本为是 v4.20.0
extract-text-webpack-plugin 当前通过install默认安装到的版本是v3.0.2

问题描述

使用extract-text-webpack-plugin在打包是提示错误

(node:12712) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
    E:\***\myproject\webpack-vue-elementUi\node_modules\webpack\lib\Chunk.js:460
                    throw new Error(
                    ^

    Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
        at Chunk.get (E:\***\myproject\webpack-vue-elementUi\node_modules\webpack\lib\Chunk.js:460:9)
        at E:\***\myproject\webpack-vue-elementUi\node_modules\extract-text-webpack-plugin\dist\index.js:176:48
        at Array.forEach (<anonymous>)
        at E:\***\myproject\webpack-vue-elementUi\node_modules\extract-text-webpack-plugin\dist\index.js:171:18
  •  

问题分析

看官网也有这个问题,extract-text-webpack-plugin还不能支持webpack4.0.0以上的版本。有个这样的描述
这里写图片描述
既然出现这个问题了,那基本上你用的webpack版本一定是4.0.0以上的了。
查看下package.json里

{
    "name": "react-demo",
    "version": "1.0.0",
    "devDependencies": {
        "css-loader": "^1.0.0",
        "extract-text-webpack-plugin": "^3.0.2",
        "html-webpack-plugin": "^3.2.0",
        "style-loader": "^0.23.0",
        "webpack": "^4.20.2",
        "webpack-cli": "^3.1.1"
    },
    "dependencies": {}
}

解决办法

npm install --save-dev extract-text-webpack-plugin@next
会下载到+ [email protected]
然后在打包就正常了

{
    "name": "react-demo",
    "version": "1.0.0",
    "devDependencies": {
        "css-loader": "^1.0.0",
        "extract-text-webpack-plugin": "^4.0.0-beta.0",
        "html-webpack-plugin": "^3.2.0",
        "style-loader": "^0.23.0",
        "webpack": "^4.20.2",
        "webpack-cli": "^3.1.1"
    },
    "dependencies": {}
}

猜你喜欢

转载自blog.csdn.net/dz45693/article/details/82865428