Build tools: We’ve enabled running WordPress from /src again

In May 2018 we’ve introduced a build step to WordPress core development as preparation to WordPress 5.0. While these changes never ended up in 5.0, the idea was to reorganize the way the JavaScript in WordPress is managed and structured so that it would be easier to include Gutenberg.

Since then, it was no longer possible to run WordPress from the src folder. This gave some issues, especially with developing WordPress core PHP. Today, @atimmer committed a patch which allows developers to build into src again.

Developers can now run grunt build --dev to build the JavaScript and CSS into src and use grunt watch --dev to automatically rebuild JavaScript and CSS files when their source is changed.

Advantages

The biggest advantage of running WordPress from src is that changes in the PHP are immediately reflected on the server again, without an extra build step. If you are only making PHP changes, then you can now build the JS and CSS once using grunt build --dev and continue coding PHP like you were used to.

Backwards compatibility

This change is fully backwards compatible with the previous setup. grunt build without the --dev flag still works exactly the same. No setups based on it should break.

Up next: Use Webpack to build all JavaScript and CSS

There’s an effort going on to move all JavaScript and CSS build logic into the Webpack configuration. Work done on this so far promises to reduce build times significantly. Especially rebuilds triggered by grunt watch should become much faster. Relevant ticket: Use Webpack + NPM scripts to build all the things.

#build-tools, #grunt