serverless-nextjs / serverless-next.js

⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
MIT License
4.45k stars 455 forks source link

Example should be target: severless #15

Closed justinwhall closed 5 years ago

justinwhall commented 5 years ago

Next Config should be target:serverless no?

Also, npm run dev doesn't work really right now. May want to remove that script for now to climate confusion. However... What are you doing for a dev server? Right now, I'm maintaining two different servers essentially.

1) Express for local dev 2) lamba/severless for anything but loca.

danielcondemarin commented 5 years ago

Thanks for reporting @justinwhall I've updated the example to use target: serverless. Also, npm run dev should work fine now. Wasn't working before because it was trying to use the assets from S3. The assetPrefix should only be set in test or prod really.

justinwhall commented 5 years ago

YA! I did notice the assetPrefix, even with removing that a route like http://localhost:3000/post/9/ does not work while in dev which is expected as Next doesn't know about that route.

danielcondemarin commented 5 years ago

Ah you're right. Right now the best I can think of is using serverless-offline, which will make the routing work, but then for local development is not great because HMR won't work. Will leave this open and look over the weekend what can be done 👍

justinwhall commented 5 years ago

^^ Yar! serverless-offline works great. But no HMR.

Regardless, plugin works great. Brings parody top client/SSR query.foo. Nice work here.

romainquellec commented 5 years ago

One solution I can think of is using assetPrefix only in production using phase : https://github.com/zeit/next.js#custom-configuration

justinwhall commented 5 years ago

One solution I can think of is using assetPrefix only in production using phase : https://github.com/zeit/next.js#custom-configuration

This won't help with HMR during development though?

romainquellec commented 5 years ago

It shoud ! In dev (next dev), assetPrefix is unset, so next loads the assets as usual and in prod, serverless load the asset generated by the plugin.

danielcondemarin commented 5 years ago

Duplicate of: https://github.com/danielcondemarin/serverless-next.js/issues/59