-
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
Pack individual functions using the new packageFunction hook #60
Comments
@m3rls would you be willing to share your webpack config? I'm having trouble packaging functions individually and would appreciate it |
@activefx sure, it's pretty minimal: module.exports = {
entry: './handler.js',
target: 'node',
module: {
loaders: [
{ test: /\.json$/, loader: 'json' }, {
test: /\.js$/,
loaders: ['babel'],
include: __dirname,
exclude: /node_modules/,
}
]
}
}; I've had to use the latest version of |
Thank you for sharing @m3rls, I must be missing something else then |
it would be great indeed. I've checked out the new "packageFunction" related methods in Serverless and adding a hook on Anyone willing to give it a try? |
This has to be checked again as soon as #130 is merged, to see if there is still anything to do here. |
So all my files actually live in a src directory. My webpack config was dealing with this previously. #176 is a possible fix. If others agree I'll update docs etc. in serverless.yaml I added custom:
webpackBasePath: './src' |
@johnf I think you did not declare your handlers properly in your serverless.yml. Serverless itself relies on the fact that you specify your handlers there relative to your service root directory. In your case this would be:
The new package/deploy function support works with and without the webpack plugin. Imo, having a separate base path definition only for the webpack plugin would introduce a different behavior when the plugin is enabled or not. As an example, we have our handlers separated from the actual implementations in
There is no need to set a base path - Serverless (and the plugin) know exactly where to find the handlers. We could even distribute the handlers to completely independent paths under the service directory to create a separation. Defining a common base path would not make any sense at all. Additionally, other plugins will most likely be not compatible with the webpack plugin if you introduce a plugin specific base path definition. So I suggest just to declare the handlers properly and everything will work. |
@HyperBrain thanks don't know why I didn't think if that it's fairly obvious. Have updated and looks good now |
BTW: I implemented the support of the service wide |
I'll close this task as the problem is solved and individual packaging is now fully supported in |
Hi,
I've noticed that when trying to deploy individual functions (with
package -> individually: true
in serverless.yml) the change made in #48 has fixed the exception (thank you!), but the function isn't being packed.In my use case, this leads to a ~19MB .zip being uploaded compared to a ~600kb .zip when I do a full deploy.
A Pull Request was merged and released along with the serverless 1.2.0 milestone yesterday that added a
before:deploy:function:packageFunction
hook, which I have (naively and probably incorrectly) added toindex.js
as follows:So now when I run
serverless deploy function --function <myFunction>
it packages it (as illustrated below):Without hook:
With hook:
Would it be possible to please have support for this hook added at some point? I'm happy to make a pull request for it if the way I've added it is acceptable, but didn't want to just assume it was correct.
Thanks
The text was updated successfully, but these errors were encountered: