From 2e8f925d87b9e237e0fc04167f34737de2f1c4bd Mon Sep 17 00:00:00 2001 From: Tynan Ford Date: Wed, 8 Nov 2023 15:14:04 -0800 Subject: [PATCH] Create v2-migration.md --- docs/v2-migration.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 docs/v2-migration.md diff --git a/docs/v2-migration.md b/docs/v2-migration.md new file mode 100644 index 0000000..8938071 --- /dev/null +++ b/docs/v2-migration.md @@ -0,0 +1,26 @@ +# Migrating from PV Info 1.x.x to 2.0.0 + +The first step when migrating to version 2.0.0 is to delete the node_modules directory for PV Info and regenerate it with `npm install`. This will install Vite and the dependencies needed to run and build PV Info. + +Vite configuration is done in the vite.config.js file. We have configured this file to try to best match the experience with Create React App. For instance, all env variables prefixed with `REACT_APP` will still work with Vite. The development server should also still work on localhost port 3000. + +The major difference to be aware of is that Vite does not use the `PUBLIC_URL` environment variable that Create React App did. Instead, Vite uses the `base` variable in vite.config.js to let production static builds be hosted on the non-root endpoint of a domain. (https://vitejs.dev/guide/build.html#public-base-path) + +For PV Info, we already included the `REACT_APP_ENDPOINT` variable in the .env or .env.local file to configure what endpoint of the domain PV Info is hosted on. Now, this variable is used to also configure the `base` variable for Vite. For instance, to achieve a build for the following URL https://mydomain.gov/pvinfo you would use `REACT_APP_ENDPOINT=/pvinfo` + +There are no changes needed anymore in package.json. + +### TL;DR + +- `rm -r node_modules && npm install` +- Use `REACT_APP_ENDPOINT` instead of `PUBLIC_URL` or homepage variable in package.json +- All REACT_APP_* variables in .env should stay the same + +### Old notes for configuring PV Info 1.x.x application + +This was only required for Create React App builds (PV Info version 1.x.x) + +- Update the "homepage" variable in [package.json](package.json). + - https://github.com/ChannelFinder/pvinfo/blob/master/package.json#L3 +- You can also use the `PUBLIC_URL` environment variable to override the homepage string, for instance during npm run +build: `PUBLIC_URL=http://myhomepage/pvinfo npm run build`