department-of-veterans-affairs / next-build

Front-end templating, build, and deploy for VA.gov CMS content.
Creative Commons Zero v1.0 Universal
9 stars 5 forks source link

Next Build Compiled files for dev and staging #550

Open mreed101 opened 4 weeks ago

mreed101 commented 4 weeks ago

Description

Currently inside of next build, the application always points to the 'prod' s3 bucket to grab the code splitting files generated by Next.js. We need next-build to grab its compiled files based on where the application is being ran (i.e, dev, staging). To help with the work being done in #538 we will need to create a .env file for our dev environment and make sure that the proper environment is being referenced when we attempting to access compiled files to prevent CSP and CORS errors.

Supporting Details

The path to the compiled files can be found at https://github.com/department-of-veterans-affairs/next-build/blob/867a6aaa01ce82bc065ed8ebdf0d065bca36fa23/next.config.js#L16C1-L17C1 Ideally assetPrefix should point to the proper bucket (prod,dev,staging) based on what APP_ENV has been set to. AWS Bucket locations can be found in the infrastructure.md file

Acceptance Criteria

Testing

For testing you should be able to build the application and set APP_ENV=dev. Doing so should allow you to check your network path and make sure that the paths are what we are expecting. An example of what this looks like when it is not working can be seen at https://dev.va.gov/outreach-and-events/events/68114/ This fix is just for the code split files and not the .css or font assets

Image

jcbolling commented 1 week ago

Updated next.config.js with changes to support compilation of static files for dev and staging environments.