3 ms·
I like create react app a lot but i wish there was an easy way to add a second page. I tried doing this recently and found it was actually easier to implement r
by gggdvnkhmbgjvbn 9y ago
I like create react app a lot but i wish there was an easy way to add a second page. I tried doing this recently and found it was actually easier to implement react router with code splitting to avoid loading my main page's huge js file.
- oelmekki 9y agoI always do that, actually. I see what is provided in the App.js file as just a placeholder, meant to be replaced. Since you have webpack, you can import files from all over the place, deciding how to organize your project. It works just fine without ejecting :)
- acemarke 9y agoI think the issue the parent is referring to is that CRA's Webpack configs only define a single "entry point", for your index.js, where each entry point becomes a separate bundle in and of itself. Having multiple entry points, like an "app page" and an "admin page", would require editing the Webpack config, which CRA deliberately keeps abstracted and hidden away until you eject. If you really want to be able to modify the Webpack config for a CRA app, you have a couple other options besides ejecting: - Create your own custom fork of the react-scripts ( https://github.com/facebookincubator/create-react-app/tree/master/packages/react-scripts https://github.com/facebookincubator/create-react-app/tree/m... ) package that CRA uses - Use the react-app-rewired (https://github.com/timarney/react-app-rewired https://github.com/timarney/react-app-rewired) tool , which lets you override parts of the build config within your project.
- oelmekki 9y agoOh, you're right, thus the "huge js file". Thanks for pointing it.