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

Compiled output from relative paths not contained in .webpack directory #49

Open
ryaninvents opened this issue Feb 1, 2018 · 2 comments

Comments

@ryaninvents
Copy link

ryaninvents commented Feb 1, 2018

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.

@jogold
Copy link
Contributor

jogold commented Feb 2, 2018

Hi @r24y,

In your setup where are your package.json and webpack.config.js located?

@ryaninvents
Copy link
Author

They're under my-project/deployment; I've updated my comment.

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

No branches or pull requests

2 participants