aws-sdk-js现在正式支持 browserify。您可以在我的博客上了解为什么这是一件好事。
我创建了一个名为serverless-plugin-browserify的无服务器插件,它将以非常少的配置完成所有繁重的工作。
为了具体回答这个问题,我用这个 browserify 配置解决了这个问题:
{
disable: false, //Not an official option, used as internal option to skip browserify
exclude: [], //Not an option, but will use for setting browserify.exclude() if defined in yml
ignore: [], //Not an option, but will use for setting browserify.ignore() if defined in yml
basedir: this.serverless.config.servicePath,
entries: [],
standalone: 'lambda',
browserField: false, // Setup for node app (copy logic of --node in bin/args.js)
builtins: false,
commondir: false,
ignoreMissing: true, // Do not fail on missing optional dependencies
detectGlobals: true, // We don't care if its slower, we want more mods to work
insertGlobalVars: { // Handle process https://github.com/substack/node-browserify/issues/1277
//__filename: insertGlobals.lets.__filename,
//__dirname: insertGlobals.lets.__dirname,
process: function() {
},
},
debug: false,
}
您可以在此处查看我的完整代码以及此处的完整示例