Serverless-next.js: How to support multiple environments

Created on 1 Oct 2019  Β·  5Comments  Β·  Source: serverless-nextjs/serverless-next.js

Hello, is there a way to support multiple environments with the new serverless component? We've upgraded and used to pass env vars to serverless.yml which no longer seems to be an option.

next component

Most helpful comment

Hi folks, I've just released @1.3.0 which adds support for custom app directory paths (see here nextConfigDir). Credits to @jayarnielsen for implementing πŸ™Œ

I'm closing the issue as you should now be able to do something like:

β”‚   next.config.js    
β”‚
└───pages
β”‚   β”‚   index.js
β”‚   β”‚   users.js
β”‚   β”‚   ...
β”‚   
└───dev
    β”‚   serverless.yml
└───prod
    β”‚   serverless.yml
# dev/serverless.yml
myNextApp:
 inputs:
  domain: [ "dev", "myapp.com" ]
  nextConfigDir: "../"

All 5 comments

@justinwhall Would this https://github.com/serverless/components#environment-variables help?

I'm not sure. I'm familiar with passing env vars to the serverless.yml but I'm not certain where they would go with the update?

Components are a new concept to me. Perhaps I'm missing something here but as far as the serverless.yml config goes, I'm not certain how both generate or conditionally deploy to different components – or perhaps that wrong terminology. Same component but different Apps.

What I'm after here is a way to build/deploy different environments something like sls deploy --env=stage

Does that make sense?

I suppose this is what I'm looking for. Does this package support something like:

myApp:
  component: serverless-next.js
  inputs:
    code: ../

With a directory structure like:

code/prod
code/test

Edit: Ok, no. I see the docs on inputs now.

Hi,

how could i manage different stages, specifying different cloudfront distributions, buckets and lamba for each stage?

Hi folks, I've just released @1.3.0 which adds support for custom app directory paths (see here nextConfigDir). Credits to @jayarnielsen for implementing πŸ™Œ

I'm closing the issue as you should now be able to do something like:

β”‚   next.config.js    
β”‚
└───pages
β”‚   β”‚   index.js
β”‚   β”‚   users.js
β”‚   β”‚   ...
β”‚   
└───dev
    β”‚   serverless.yml
└───prod
    β”‚   serverless.yml
# dev/serverless.yml
myNextApp:
 inputs:
  domain: [ "dev", "myapp.com" ]
  nextConfigDir: "../"
Was this page helpful?
0 / 5 - 0 ratings