-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
It is not a component, so it should not be in the `components` directory
CRA opens localhost:3000 at root path, which is not where the app is served
Instead of ejecting, the `config-overrides.js` file should be used to configure CRA as desired
Allows for simpler setup ("development" with `npm start` and "production" with `npm run build`, simplifies env variables), consistent with React app
Allows multiple, environment-dependent env files. Makes the behavior of the Angular and React apps more consistent
* Add docs on PWA and code splitting * Fix broken links * Remove duplicate content * Put all archetype docs into root README, project-specific docs into `archetype-resources` dir, frameworks-specific docs into `angular-app`/`react-app` dirs
Should only be used in demo
@samuelmeuli , @pfauchere after a little digging I feel strongly that we should not bootstrap projects with the react-app-rewired. Looking at the Readme for the react-app-rewired it appears there is limited support and it falls outside of "official" recommendations by React/facebook. This, of course, is fine for many customers but they need to understand the risks ahead of time. Since all SPA editor projects should start from the archetype this seems like a dangerous path to send customers down by default. I'd prefer to stick as close to: https://create-react-app.dev/docs/making-a-progressive-web-app as possible. Forgive me @samuelmeuli, remind me again what functionality the rewired-app provides that we needed? Maybe we can solve some of this at the Dispatcher/Apache level for things like loading the Service Worker at the root of the site? If there are some features of PWA that require the app to either be ejected and/or use react-app-rewired then maybe we can document these steps instead of forcing customers to not use CRA? |
@godanny86 I agree that using The main problems that need to be solved are the following:
Possible solutions we've identified:
The situation for Angular is pretty much the same. The service worker and manifest files generated using My preferred approach would be 3, and possibly 2 and 5. @godanny86, please let me know what you think or if you have any other ideas :) cc @pfauchere |
hi @samuelmeuli, thank you for the detailed response! The complexity of this problem is not lost on me and you have explored many different solutions. My point is that the archetype should be a starting point to accelerate a customer project but not at the cost of choosing an implementation path. To your point, there seems to be several approaches for implementing a PWA and without a definitive consensus, I think we should let projects choose the most appropriate path based on their app requirements. My approach would be to continue to provide as basic of a project as possible and add as many PWA features that we can. If some advanced configurations like complete off-line functionality, advanced caching, and code-splitting cannot be achieved then so be it. We can still provide samples and recommendations on how to achieve these advanced configurations and let projects decide how to implement them. At least we are moving projects closer to PWA and in the future, if it turns out most customers want/need those advanced configurations we can make a determination then... |
* Use fork of `create-react-app` to get custom SW and code splitting without having to use `react-scripts-rewired` * Use `open-cli` to launch web app on `npm start` (avoids confusion because web app is served on a subpath and errors are logged when visiting the root path) * Update service worker template for the latest Workbox beta * Specify manifest and favicons by hand instead of using a Webpack plugin for consistency with CRA * Rename env var back to `PUBLIC_URL` for consistency with CRA * Rename React root div for consistency with CRA * Add checks that required env vars are defined * Remove unused dependencies
This PR configures the archetype to generate projects with features of a Progressive Web App.
The features can be tested using Lighthouse. All checks should pass with this setup.
react-app
andangular-app
folders.react-scripts-rewired
, code splitting is now possible and configured to work by default with React (see the docs).environment.ts
file (for consistency with the React app and to allow the usage of the variables in the Webpack configuration and service worker template).Note: Currently, all files are served by AEM with a
Service-Worker-Allowed
header. This will be improved in a future PR using a Servlet Filter (so only service worker files are served with that header).