Hi,
One of the dependencies that I use includes binary files. I want those binary files to be packed in the output zip file so the lambda functions can use them during runtime.
How can I achieve that?
I already tried to use 'file-loader' in webpack.config.js which didn't work and I tried in my serverless.yml
custom:
webpack:
includeModules:
forceInclude:
- module_name_with_binary_files
All I get are just transpiled js files of my functions.
Hi @panzupa , the file-loader is wrong for that use case as it will only include and use files that are "required" and forceInclude only is for node modules.
You can can include arbitrary files (binaries) with the webpack copy files plugin. Then webpack will copy the specified files or folders as is to the given target location within the package.
hi @panzupa
Using the plugin @HyperBrain has mentioned I'm copying a file called .serverless-secrets.json (generated by https://github.com/trek10inc/serverless-secrets plugin) to my output zip file by appending the following to my webpack.config.js.
(...)
const CopyWebpackPlugin = require('copy-webpack-plugin');
(...)
plugins: [
new CopyWebpackPlugin([
'.serverless-secrets.json'
])
]
Finally, I had time to check your advice.
It works flawlessly.
@HyperBrain @franciscocpg thank you very much!
I'll close this issue as it works for you 馃槃
Most helpful comment
hi @panzupa
Using the plugin @HyperBrain has mentioned I'm copying a file called
.serverless-secrets.json(generated by https://github.com/trek10inc/serverless-secrets plugin) to my output zip file by appending the following to mywebpack.config.js.