cra-build-watch
cra-build-watch copied to clipboard
feat: React workspaces and css loaders
Hey 👋
First of all thanks for building this out, it's been quite helpful
This PR introduces two changes that I needed, and I think some people in the community needed:
-
Introduce a new config flag
use-react-workspaces
- My project is setup with lerna & react workspaces so I use the
@react-workspaces/react-scripts
versions ofreact-scripts
- The config flag just pretends
@react-workspaces/
to everywhere you previously usedreact-scripts
- My project is setup with lerna & react workspaces so I use the
-
Add in
MiniCssExtractPlugin
which will bundle any CSS files imported in a react component such asimport '../styles/index.css';`
- The bundled CSS file will then be included as part of the
index.html
s<head>
section - To do this I had to filter out
style-loader
which I believe appends it at run-time usingwindow
- The bundled CSS file will then be included as part of the
I understand that these changes might not suit the overall direction of the project, particularly because introducing MiniCssExtractPlugin
introduces an explicit dependency on a webpack version (if someone can tell me how to get around that it would be even better
If you think I should split these changes up I will happily do that too, I was just solving my own problems as I went and figured it would be best to contribute back.
Thanks again