Is there a nx specific w…
Is there a nx specific way of deploying to now? (or I guess it’s called vercel now) just wondering since now tends to have all this “magic no config thingy” and for example deploying a storybook output would be useful
Responses:
Expanding on that, having the option to deploy several different now apps would be useful as well. Does anybody know about an example of something like this using nx?
if you install the Now CLI you can configure something like this for different projects:
"deploy-now": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "now --confirm"
}
],
"cwd": "dist/apps/frontend-react"
}
},
you can then do something like nx run-many --target=deploy-now --all
to deploy all apps that have that target/architect defined
This only works for static assets btw - deploying Next.js apps is currently not supported, as they don’t offer monorepo support yet - if you want to deploy next.js apps, there’s an article on deploying to Heroku: https://blog.nrwl.io/painlessly-build-and-deploy-next-js-apps-with-nx-225e2721da78
I’ve also written a blog post that goes into a lot of detail on deploying to Netlify, including setting up CI etc.: https://www.netlify.com/blog/2020/04/21/deploying-nx-monorepos-to-netlify/
Awesome that is exactly what I was looking for. And you answered my next question for me, next.js I mean :wink: Currently I’ve set it up to build, and then I just copy the build result into a docker container that has the front end dependencies etc which seems to work, but not coupled into the nx setup like this would be. Using this approach I assume I could run any command, for example make
or even just docker build
?
Couldn’t I just set up a deploy
config for each project that needs to be deployed and then run the target=deploy --all
and that would run all deploy scripts regardless of whether it’s now or docker build push etc?
Found the documentation on nx.dev for the run commands builder. Thanks for your help!