devloco / create-react-wptheme

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

Support for other template files #54

Closed Jtosbornex closed 4 years ago

Jtosbornex commented 4 years ago

Since the JS and CSS are injected into the index.php, we don't easily know on runtime what the URL of the assets will be.

If I make a custom template, how can I utilize the build pipeline and have the asset urls injected here as well?

Jtosbornex commented 4 years ago

I ended up creating my own starter build FYI.

javierZippia commented 3 years ago

@Jtosbornex I am facing a similar issue, can you please provide more info of how to create your custom starter? thanks

Jtosbornex commented 3 years ago

@javierZippia I will give you a high level overview of what I am doing. Its kind of a two step process and its not perfect.

I have a file watcher running that is looking for changes in the JS source and then outputting the build.

in functions.php im reading in the asset manifest file in order to include all of the built JS and CSS.

I have a socket running on the frontend that is connected to a socket in the build job. When a build is complete, the socket tells the front end to refresh the page.

It did what I needed it to but it could be optimized if I was using incremental builds and webpack devserver.