devloco / create-react-wptheme

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

Builds put the theme files in a sub directory of the theme #31

Closed mikelinden1 closed 4 years ago

mikelinden1 commented 4 years ago

Hi there. When I run the build command the theme files are created in a subdirectory of my theme (ex: my-theme/my-theme/style.css). I created a new theme to be sure the issue wasn't something related to my theme and saw the same behavior. Any ideas?

devloco commented 4 years ago

If I understand you correctly, that is by design. Check out the deploying instructions here:

Deploying Your Theme

I have struggled with this a bit... how best to communicate to the user about differences between dev and prod. I'm coming up with more ideas... some of the other issues I've filed for myself in here are in that regards.

Let me know if I misunderstood you. Also, any ideas around developing vs deploying are welcome.

Thanks!

mikelinden1 commented 4 years ago

I see. Yes, that's what the documentation says. For our use-case it would make more sense if the files were in the root of the theme so when we deploy via git it works as is. This way I need to create a wrapper around yarn build that moves the generated files.

devloco commented 4 years ago

Yah, I just ran into so many people that didn't understand the folder layout for this project, and they would deploy their theme to prod, but ended up with the react-src folder on their prod server. Which... even worse, contains the node_modules folder. Ugh!

Like I mentioned, I am going to revisit the whole build process. Lots more hand-holding. But I think I can also add a setting or two to the user.prod.json file. Maybe an onSuccessMoveToFolder type of thing.

Someone else a while back had a similar work flow to yours. I recommended shelljs. Here's the issue link: #14 if you're interested.

I'm going to leave this ticket open for now, and look at it when I do the "build revisit".

Thanks!

mikelinden1 commented 4 years ago

Adding a configuration option for this would be great! Thank you for making this project

devloco commented 4 years ago

This is done in the latest release: 3.2.0-wp.2.

Inside the user.prod.json file you can add a new property named "finalBuildPath" and when you run npm run build inside the react-src folder, your compiled files should end up where you want them. I tested with a value of ".." so that they would end up in the theme's root folder, like you wanted.

Here's the contents of the user.prod.json file I tested with:

{ "finalBuildPath": "..", "homepage": "/wordpress/wp-content/themes/foobar" }

Let me know if it doesn't work for you.

Thanks!