错误提示
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }
原因
使用webpack5的原因
v5 与 v4
v4以前附带了许多node.js核心模块的polyfill
,在构建时给 bundle附加了庞大的polyfills,在大部分情况下,polyfills并不是必须。
现在v5将要停止这一切,在模块的应用中不再自动引入Polyfills
,明显的减小了打包体积