Webpack 4最后兼容的loader

September 01, 2021

Why not use Webpack 5 ?

因为目前有些大型的项目还在依赖Webpack4,比如我正在用的Storybook和flareact。

如果安装最新版的各种loader,最常见的错误就是TypeError: this.getOptions is not a function,所以要么开发时锁定loader版本,要么根据我下面的列表进行调整devDependencies。

Lastest version of Webpack4 loaders

Webpack4对于mjs文件处理存在问题,可以增加一条以下规则:

{
    test: /\.mjs$/,
    include: /node_modules/,
    type: "javascript/auto",
}

Copyright © Arcto 2022, Built with Gatsby