wp-dev-lib
wp-dev-lib copied to clipboard
Add default Grunt/Gulp file
There is a Gruntfile.js
in wp-foo-bar which can be moved into this project and added in to foo-bar either as a symlink or required-in as a dependency that the project Gulp/Grunt file can extend/integrate.
I suggest that we might even be able to eliminate svn-push
in favor of re-using Grunt script, like using grunt-wp-deploy
.
Here's one such Gruntfile: https://github.com/xwp/wp-customize-posts/blob/develop/Gruntfile.js
If we could factor out the logic from this Gruntfile into dev-lib to allow it to be require
'd into a project's specific Gruntfile, then we could eliminate having to duplicate the Gruntfile for each project. And we could start to standardize on using Grunt/Gulp for doing scripting where modules already exist instead of using Bash or PHP directly, if that makes sense.
Ideally we'd be able to just symlink to a the Gruntfile.js
inside of the dev-lib
submodule and have it automatically configured to do the right thing. This is preferred over having to copy the Gruntfile.js
out into the repo. Additional configurations could be provided for the Gruntfile.js
via the package.json
or perhaps .dev-lib
.
How would we handle cases where the Grunt configuration is quite different? For example, some project may not need many of the tasks included, or may have separate locations for files to process.
If we use something like load-grunt-config, this would allow us to have one Grunt and separate out tasks into their own location, allowing a specific project to provide its own tasks (if needed).
@kopepasah I would expect the configuration file to be filled in on a per-project basis, as the paths are always unique. And one can eventually turn on/off features using flags setup to true or false in the config file.
This is being worked on in https://github.com/xwp/wp-dev-lib/pull/245 We've done good progress on a general FE workflow, but the scripts can be further improved upon once we start using this in production.
There was one thing we discovered: "Ideally we'd be able to just symlink to a the Gruntfile.js inside of the dev-lib submodule and have it automatically configured to do the right thing. This is preferred over having to copy the Gruntfile.js out into the repo.". We need the package.json to be outside of the dev-lib folder because if we try to run it from inside the dev-lib folder, we can't "go outside of the directory" to do our thing.
At this moment it means one needs to copy the package.json outside. This also contains configuration data (what's the theme folder and what js files need compiling / etc., what plug-ins require js compilation) so it makes sense to stay in the project's repository.
The actual tasks are referenced from inside the dev-lib from the package.json, and this makes a minimal amount of additions to the projects repository.