Skip to content
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

Fixes #107 Hook on "deploy function" command #110

Closed
wants to merge 1 commit into from
Closed

Fixes #107 Hook on "deploy function" command #110

wants to merge 1 commit into from

Conversation

HyperBrain
Copy link
Member

@HyperBrain HyperBrain commented Mar 3, 2017

Fixes #107: This fix hooks the webpack plugin onto the Serverless "deploy function" command. Currently the plugin will webpack the service as it would be done with a regular deploy. Then the single selected function is deployed by Serverless.
This makes the whole thing work. However there could be some improvements done later. Maybe this.options.f can be used in this case to restrict the webpack run to create only the selected function entry point. But finding that would not be trivial.
I suggest to approve this solution on the first hand and handle the rest as improvement.

This fix hooks the webpack plugin onto the Serverless "deploy function" command. Currently the plugin will webpack the service as it would be done with a regular deploy. Then the single selected function is deployed by Serverless.
This makes the whole thing work. However there could be some improvements done later. Maybe _this.options.f_ can be used in this case to restrict the webpack run to create only the selected function entry point. But finding that would not be trivial.
I suggest to approve this solution on the first hand and handle the rest as improvement.
@HyperBrain HyperBrain changed the title Issue #107 Hook on "deploy function" command Fixes #107 Hook on "deploy function" command Mar 3, 2017
@mnightingale
Copy link

This doesn't seem to work when you have multiple entry/outputs in webpack.config.js similar to using the example config from https://webpack.github.io/docs/multiple-entry-points.html

$ sls deploy function -f x
Serverless: Deploying function: x...
Serverless: Bundling with Webpack...
ts-loader: Using typescript@2.2.1 and /Users/XYZ/tsconfig.json
Time: 1248ms
Asset Size Chunks Chunk Names
x.js 620 kB 0 [emitted] x
y.js 4.5 kB 1 [emitted] y
z.js 3.21 kB 2 [emitted] z
Serverless: Packaging function: x...
path.js:7
throw new TypeError('Path must be a string. Received ' + inspect(path));
^

TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.basename (path.js:1355:5)
at fse.copy (/Users/XYZ/node_modules/serverless-webpack/lib/cleanup.js:37:22)
at doneOne (/Users/XYZ/node_modules/fs-extra/lib/copy/ncp.js:237:40)
at /Users/XYZ/node_modules/fs-extra/lib/copy/ncp.js:122:11
at /Users/XYZ/node_modules/graceful-fs/polyfills.js:239:18
at FSReqWrap.oncomplete (fs.js:112:15)

@martinmicunda
Copy link

@mnightingale The error is caused by after:deploy:function:packageFunction if you remove that part of the code it works however I found another problem when you run sls deploy function -f test it will create .serverless folder under .webpack directory so structure looks like this:

|-.webpack
    |-.serverless
         |-test.zip

and this cause follow error as the serverless expact zip file to be under .serverless in root folder not in .webpack:

ENOENT: no such file or directory, open '<-your-path->/.serverless/test.zip'

My current solution is below but is not ideal however it still better then deploy cloudformation during development:

sls package -v && sls deploy function -f test -v

@franciscocpg
Copy link
Member

Hello @martinmicunda .
This PR #130 should fix it.

@HyperBrain HyperBrain mentioned this pull request Jun 30, 2017
@HyperBrain
Copy link
Member Author

Superseded by #130

@HyperBrain HyperBrain closed this Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single function deploy does not invoke the plugin
4 participants