-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serverless include/exclude is not processed #64
Comments
no one? |
I just recently ran into this issue as well. I would certainly like to see the webpack plugin including/excluding based on the values in the serverless.yml but I don't currently have the time to develop it myself. |
the exclude/include thing looks neat and we should find a way to make it easy to use it together with webpack. I still don't have a clear idea about it. The thing is, with webpack you basically shouldn't want to include/exclude anything via serverless as the whole process should be handled by the webpack bundling process. however clearer docs/examples on this would definitely help in using this plugin. Opinions/suggestions are welcome! |
At the time I ran into this issue, I was using a setup similar to https://github.com/vitaly-t/pg-promise-demo where sql queries are being stored in external files. However, the pg-promise library doesn't require/import these and so they weren't being bundled by webpack. After having done some more digging into webpack, I manged to get the raw-loader to add the files when bundling so my use case for this is currently solved. |
@thenikso One reason to keep exclude/include and process them only after webpack has finished is for included binaries. I have a portable binary that I ship with my lambda and I've struggling to include that whole directory with webpack. Edit: I found the webpack loader: copy-webpack-plugin which suits my use case. Edit 2: Actually copy-webpack-plugin does not preserve permissions so I'm just running a shell script before the build with webpack-shell-plugin to copy over the binaries. |
@RubenSandwich any chance you could post your webpack config for the binary copying? TIA EDIT: I was able to work this out. |
@rstims Sorry for the wait. I'm happy you were able to work it out. I don't have that code anymore as my team ultimately decided to move away from binaries in our lambda deployment and instead moved towards another solution because static linking all of the binaries we needed turned out to be a pain and not easily reproducible and our project requirements demand it to be easily reproducable. But the gist of what I did was use webpack-shell-plugin to run a shell command that did two things on the onBuildStart hook:
I also cleaned up the webpack-shell-plugin to be less console happy: https://github.com/CMP-Studio/webpack-shell-plugin. |
Thanks so much @RubenSandwich , I was frustrated with this. In my case just by using: plugins: [
new CopyWebpackPlugin([
{
from: path.join(__dirname, "binary-file")
}
]) Solved the issue |
@alfonsoperez Yes. Using the CopyWebpackPlugin is the way to go to include arbitrary files into the output package. Can I close this issue, or is there anything left, that's blocking from deployment? |
|
I am a little confused how to do this on a per function basis if I have
If I do Then it will copy the file into every Lambda. How can you make it work, so it'll only copy the file to the relavent lambda? |
That would be great if we could have a mechanism in place to respect serverless include/exclude configs, whether service-wide or function-wide. |
as i have seen there are/were already issues where part of this problem were discussed.
does it make sense at all? in my special case i needed the
package.json
(and especially thename
andversion
)-property inside AWS.i achieved it using the existing
packExternalModules
-functionality and using the existingpackage.json
-Content without all dependencies for thetmpPackageJson
. see commit hereThis works for my special Case (maybe it is generally i good way to do this, if you too think i can provide a pull request for this).
What would be better i think is to make the include from serverless work. If you think this would make sense, i'm willing to contribute and make a pull request for that one. just let me know in this issue!
The text was updated successfully, but these errors were encountered: