Webpack - How do you require an optional dependency in bundle (saslprep)

前端 未结 3 1937
[愿得一人]
[愿得一人] 2021-01-19 16:09

I am using webpack to bundle a number of back-end scripts into a single file during my deployment process.

When connecting to the MongoDB database there is an option

3条回答
  •  梦毁少年i
    2021-01-19 16:46

    I you use the webpack-node-externals package, you can also do this:

    const nodeExternals = require("webpack-node-externals")
    
    ...
    
    const webpackConfig = {
      ...
      externals: [nodeExternals({
        allowlist: ['saslprep']
      })],
      ...
    }
    

提交回复
热议问题