ahmadawais / WPGulp

An advanced Gulp workflow for WordPress development with extensive documentation. Used by 40,000+ themes and plugins.
https://twitter.com/MrAhmadAwais/
MIT License
1.77k stars 303 forks source link

Suggestion: Separate source and build directories #24

Closed retani closed 6 years ago

retani commented 8 years ago

Hi!

I have compared several gulp scripts and like this one best. However, it bothers me that it doesn't by default separate source and build directories. Have a look at this one which which has a build and a src folder: https://github.com/synapticism/wordpress-gulp-starter-kit

I think that it's much cleaner to have such a separation rather than having the gulpfile, node_modules, etc. in your theme folder. The same is true for scss files and javascripts. It's easy to accidentally edit the compiled file (especially when working collaboratively). Another problem is the removal of (uncompiled) source files for a release. I use wordmove, so I need to exclude all the dev-only files and directories to copy.

Instead I would like to suggest to have the dev version of the theme in a folder outside of the wordpress tree, for example in you home directory. The gulp file would have to move the files inside the theme folder in wp-content. This ensures that the files in the theme folder are always the ones that can go right on a server or a release.

What do you think?

ahmadawais commented 8 years ago

@retani A major update is due to this workflow. I have on my localhost a WPGulp CLI which makes all the sense :) BTW you can have separate build folder, but I would not want that, I am still thinking about handling this one, what I am doing is I am creating a possibility to sum up different packages of your WP products into ZIPs. Production package, dev package, etc.

But having a dev theme separate from the WP Theme dir, is in my opinion, a counter-intuitive approach.

retani commented 8 years ago

@ahmadawais WP-CLI sounds cool :) I think that both approaches make sense. I am not a regular theme developer, but I am working on a dedicated theme for just one site, so I have the site running in a vagrant box and wanted to keep the source files out of it. That keeps live and dev versions in line, enabling me to sync them with mordmove. It would also facilitate versioning with git for example. I must say that I am relatively new to wordpress (well, again) and that it has it's own characteristics and workflow. Thanks for your comment.

marianrick commented 7 years ago

@ahmadawais is this still in progress? And is there a current state that could be improved or continued to be developed?

For certain reasons, I think the build different packages part is really important. While /node_modules and some other folders/files are ignored due to .gitignore, all these files are present in the themes folder.

I have used DesktopServer by Serverpress to deploy websites, which deployed these folders/files as well to the dev/live server. Later on, while trying out a FTP script, every files has been synced as well.

To make this work I would live to extend the gulpfile as far as I can to create a dev and a build version. Its hard to think about a good folder structure. So should there be "two" themes, one as dev theme and one as build version? Or should there be one theme, with a src and build folder, which seems to destroy the "wordpress way" of handling themes? I would love to hear from you or @retani (or anyone else), if there is already a good idea about this problem.

dmhendricks commented 6 years ago

@retani -

"It's easy to accidentally edit the compiled file (especially when working collaboratively)."

For the "collaborators" that stubbornly refuse to use SASS, I:

  1. Put a file in my compiled dir named .DO_NOT_EDIT.txt which contains brief instructions/reasoning.
  2. I usually let those who are sane use the SASS files, and for those who prefer clutter, inefficiency and stepping on each others toes, I just tell them to only modify the style.css file in the theme dir (assuming that it is a child theme). Occasionally, I go through that file and migrate the garbage.

"Another problem is the removal of (uncompiled) source files for a release."

For my own plugins, I use an NPM script to ZIP up my plugin for distribution, minus the development files. I just have to run npm run zip to create a new, updated ZIP. Perhaps something similar would work for you?

@marianrick -

"I have used DesktopServer by Serverpress to deploy websites, which deployed these folders/files as well to the dev/live server. Later on, while trying out a FTP script, every files has been synced as well."

Opinion: You would really benefit from using Git to deploy your sites. WPEngine, DreamHost, FlyWheel, any host using Plesk Onyx, and many others support Git deployment.

Off-topic: I am a DesktopServer refugee and I did a lot of research on alternative options (I almost gave up because everything had issues of its own). You might want to check out Local by FlyWheel. It is free to use (you don't have to be hosting with them), is available on Mac and Windows, and is excellent.

marianrick commented 6 years ago

@dmhendricks thanks for your suggestions, checking out Local by Flywheel right now.

ahmadawais commented 6 years ago

Take a look at how v2 handles this and see if we still need this. Then reopen if required.

brandlewco commented 5 years ago

I was reviewing the v2+ notes and couldn't find the resolution for this issue. Was there a production build process added? was it done in some other way I'm just missing?