DEV Community

Swashata Ghosh
Swashata Ghosh

Posted on

react-scripts (CRA) like tooling for WordPress

Hello everyone,

This is my first post here and I would like to share a tooling I have been developing over past 2 weeks, which I believe would give a better Development Experience for WordPress developers.

Being a traditional WordPress developer myself, I know it can be a pain to setup all those webpack stuff for every new projects. On top of, if we were to leverage the advanced code-splitting of webpack, then somehow, we would need to enqueue all chunks in the entrypoint, set dynamicPublicPath for lazy loading (import('').then()) etc.

To make things easier, I came up with an idea of abstracting the build tooling inside one single scripts (much like react-scripts). This is the outcome so far.

And this is the repo.

GitHub logo swashata / wp-webpack-script

πŸ’₯πŸ”₯πŸ“¦πŸ‘©β€πŸ’» An easy to use, pre configured, hackable webpack setup & development server for WordPress themes and plugins.


visit our website wpack.io for documentation and usage

wpack.io - Modern JavaScript tooling for WordPress

Backers on Open Collective Sponsors on Open Collective Build Status codecov npm version npm download cypress dashboard

What is wpack.io?

Put simply, wpack.io is a nodejs based build tool to ease up using modern javascript in WordPress Themes and Plugins. It gives a fine Developer Experience (DX) and a single dependency for all your bundling requirement.

It is a fine-tuned webpack/browser-sync configuration made specifically for WordPress Theme and Plugin Development.

With the rise of Gutenberg editor, the usage of modern JavaScript and libraries like react is imminent. The goal of this tooling is to:

  • βœ… Provide out of the box compiling and bundling of all front-end assets.
  • βœ… Give best in class Developer Experience (DX)
    • Hot Module Replacement and Live Reload.
    • Compile files on save.
    • Work on any local development server.
  • βœ… Support modern and useful concepts like modules, tree-shaking, dynamic import etc.

and eliminate the pain points such as:

  • ❌ Boilerplate…

Some of the features are:

πŸ‘‰ Supports Hot Reloading, right out of the box.
πŸ‘‰ Dynamic PublicPath, generated by a WP based PHP class, so use import(), code-splitting all you want.
πŸ‘‰ Can work with any local server (vvv, wamp, mamp, docker).
πŸ‘‰ Webpack Multi-Compiler support.
πŸ‘‰ Hybrid of Browsersync and webpack dev and hot middleware, finest DX.
πŸ‘‰ Zero-config, ES6+, reactjs, Sass, typescript support.

I request, if you are interested in WordPress development, please give this a try. I have not published yet, so you would need to clone it (a bit of pain) and run the example.

You would need to have docker and preferably yarn.

git clone git@github.com:swashata/wp-webpack-script.git
yarn
yarn build
cd examples/plugin
docker-compose up -d && docker-compose logs -f wordpress
yarn exstart

I would very much like to have feedbacks before I finish up the first version πŸ˜ƒ.

Top comments (0)