Compiled output from relative paths not contained in .webpack directory
My setup looks like this:
my-project/
+-- deployment/
| | package.json
| | webpack.config.js
| `- serverless.yml
`-- server/
| handler1.js
`- handler2.js
And serverless.yml:
service: my-project
provider:
name: aws
runtime: nodejs6.10
plugins:
- serverless-plugin-webpack
package:
exclude:
- './**'
include:
- '../server/**'
functions:
handler1:
handler: ../server/handler1.main
handler2:
handler: ../server/handler2.main
The problem is, when I run serverless package from the deployment directory, it creates a new directory server inside the deployment directory, which contains the webpacked code. I think it's resolving ../server from the desired .webpack directory, and "busting out" of the build folder.
I have an idea for a "quick fix": add a new rootDirectory option. When generating the filenames for the compiled output, resolve relative paths against rootDirectory instead of process.cwd(). For instance:
config:
webpack:
rootDirectory: '..'
This would cause ../server/handler1 to be resolved as ./server/handler1, which would allow the compiled output to be placed in the correct location. This solution is a bit inelegant, but it "does the trick" and can probably be implemented quickly.
Let me know if you want me to take a stab at it.
Hi @r24y,
In your setup where are your package.json and webpack.config.js located?
They're under my-project/deployment; I've updated my comment.