devloco / create-react-wptheme

Create modern, React-enabled WordPress themes with a single command.
MIT License
359 stars 60 forks source link

Attaching Stylesheet per component #53

Closed KevinDias91 closed 4 years ago

KevinDias91 commented 4 years ago

Hey guys,

First of all thank you for this tool, it's pretty useful.

I have a issue though. I wan't to improve the website's performance by avoid all the unused CSS in each page, by attaching a single stylesheet for each of my component.

I think this was possible by simply import the CSS file in the component in Create React App. But with CR-WPTheme, it just bundles all the imported CSS on a big Chunk.css file. Is there any way to avoid that (by ejecting the project, and modifiy something in the webpack config file) ?

Thank you for your answer !

devloco commented 4 years ago

Hi @KevinDias91,

Thanks for the kind words. The goal of this project is to match CRA feature-for-feature. So I’m surprised this isn’t working. And you should only ever need to eject if that’s something you’d also need to do with CRA.

I’m not much of a CSS guy, but I’ll look at this if you can give me some step-by-step instructions for reproducing the issue in my dev environment...?

Or feel free to send a PR if you see the problem in this project’s webpack.config:

https://github.com/devloco/create-react-wptheme-scripts/tree/master/packages/react-scripts/config

Both CRA’s unmodified config and this project’s config are in that folder.

Thanks, and apologies for the hassle!

KevinDias91 commented 4 years ago

Hello, thank you for the answer.

Actually, I took a look at raw CRA again, and importing the CSS includes them in a