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
How to use in Monorepo without producing tons of duplicate code. #430
Comments
In order to have multiple functions in different folders you have to add this to your webpack confg:
It takes all functions from your serverless config which contains paths to all functions handlers. For example your serverless.yml file can look like this:
When configured like this you don't need to change anything in webpack config whenever new function is added. |
@rbobko93 - I did discover this, but this makes sense if I have one serverless.yml file. I am looking at a structure more like below. Each services has a I am curious if each serverless.yml should be configured like something below - What is the best practice. Does each In a traditional node monorepo, I would have a separate package.json in each separated concerns. How do you mimic that structure with the least code copy/pasted between them. Does this make more sense? My Current Folder Structurepackage.json
webpack.config.js
.babelrc
jest.config.js
resources/
dynamo-table.yml
s3-bucket.yml
package.json
serverless.yml
services/
users/
create.js
create.test.js
list.js
list.test.js
delete.js
delete.test.js
update.js
update.test.js
get.js
get.test.js
package.json
serverless.yml
projects/
create.js
create.test.js
list.js
list.test.js
delete.js
delete.test.js
update.js
update.test.js
get.js
get.test.js
package.json
serverless.yml
etc/
... Example Service Yaml File
|
Error when running against root webpack.config.js
Root Webpack Config
|
@khrome83 did you find a resolution to this problem? I have a small Serverless project which is about to get considerably more complex and as there are only two people working on it I'm learning towards keeping a mono-repo however I'm seeing lots of people mentioning this issues so I'm unsure. |
It's possible to have a single webpack config file in a root, but as a result you must move "serverless-webpack" and "webpack" npm dependencies in a root package.json (and ignore warnings while |
Hi all, just thought I'd share how we manage similar webpack configurations in a monorepo. We use Yarn Workspaces, but you should be able to do without. We created a Then in each Serverless project inside the monorepo, you can do something like: services/users/webpack.config.js:
|
@hassankhan Could you give an example of what the |
This is a Question / Clarification
Description
How do you use this within a Monorepo. Ideally you would define a single webpack.config.js and .babelrc file, and no matter the services, it should share that config. It seems when I specify a webpack.config.js in root, it assumes the functions are located there.
What is the best practices? Is this supported?
The text was updated successfully, but these errors were encountered: