Replies: 4 comments 12 replies
-
new webpack.ProvidePlugin({
// 浏览器兼容 webpack 4 的 Buffer
Buffer: ['buffer', 'Buffer'],
// 浏览器兼容 webpack 4 的 process
'process.browser': JSON.stringify(true),
}), |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
ZakaryCode
-
|
Beta Was this translation helpful? Give feedback.
5 replies
-
chainWebpack(chain, {isServer, isClient}) {
chain.resolve.alias.set('@', path.resolve(__dirname, 'src'));
.set("crypto", "crypto-browserify")
.set("stream", "stream-browserify")
.set("process", "process/browser.js")
.set("buffer", "buffer");
chain
.plugin("provide")
.use(require.resolve("webpack/lib/ProvidePlugin"), [
{
crypto: "crypto-browserify",
stream: "stream-browserify",
process: "process/browser.js",
Buffer: ["buffer", "Buffer"],
},
]); |
Beta Was this translation helpful? Give feedback.
0 replies
-
// npm i -D node-polyfill-webpack-plugin
module.exports = {
plugins: ['node-polyfill-webpack-plugin']
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
这个特性解决了什么问题?
如题,WebPack5无法直接使用node的原生模块crypto和buffer等,请问有没有测试可行的解决方案呢?
这个 API 长什么样?
期望可以通过配置,使用WebPack5打包也可以继续使用crypto和buffer等。
Beta Was this translation helpful? Give feedback.
All reactions