WPACK.IO - Webpack dev server for WordPress

Open source

💥🔥📦👩‍💻 An easy to use, pre configured, hackable webpack setup & development server for WordPress themes and plugins.

Become a contributor

Financial contributions

Custom contribution

Donation

Make a custom one time or recurring contribution to support this collective.
Goal

backers

$500 USD / month goal

$0 USD / month raised (0%)

Support us with a small donation to keep the work going for wpack.io. It helps us release regular... Read more

Starts at

$2 USD / month

Goal

sponsor

$2,000 USD / month goal

$0 USD / month raised (0%)

Become a sponsor for wpack.io to help us release new features and spend more time on fine tuning.... Read more

Starts at

$100 USD / month

One time contribution

on boarding

For the one-time donation, the creator (@swashata) would personally help your team setup wpack.io... Read more

$1,000 USD

What's new with WPACK.IO - Webpack dev server for WordPress

Stay up to dates with our latest activities and progress.

Release Version 4

We have recently released version 4 and some other incremental updates. It was mainly focused on dependency updates.
Published on October 29, 2019 by Swashata Ghosh

WPACK.IO - Webpack dev server for WordPress is all of us

Our contributors 1

Everyone who has supported WPACK.IO - Webpack dev server for WordPress. Individuals and organizations that believe in –and take ownership of– our purpose.

Swashata Ghosh
Collective Admin

About

 wpack.io is a fine-tuned webpack/browser-sync configuration made specifically for WordPress Theme and Plugin Development. It gives a fine Developer Experience (DX) and a single dev dependency for all your javascript and css/sass/scss bundling requirements.

Screen Shot 2019-10-28 at 1.48.00 PM.png 235.5 KB
Remove
Screen Shot 2019-10-28 at 1.48.00 PM.png 235.5 KB


Add @wpackio/scripts to your project

npx @wpackio/cli
This command will install @wpackio/scripts to your project’s devDependencies. It will also create a package.json if necessary and will add a bootstrap script to your package.json.

It provides an on-boarding experience where you don’t need to worry about adding scripts and dependencies.


Bootstrap dependencies and configuration

npm run bootstrap
Or, if using yarn

yarn bootstrap
This will create all the necessary files and install all additional dependencies you might need according to your project.


Configure JS entry-points

Now edit your newly generated wpackio.project.js file and put your javascript entry-points. An entry-point is the module which runs the final javascript code on browser. It can (and should) import other modules which has export-ed something.

webpack will automatically bundle all the dependencies together. For more information read the guide.

You can have multiple entry-point under the same entry, or have multiple file entry. More information can be found in the docs.


Consume scripts & styles with PHP

First install php helper library wpackio-enqueue with composer.

composer require wpackio/enqueue
We instruct it to load the files right way, using WordPress APIs like wp_enqueue_script and wp_enqueue_style.

Everything is taken care for you when you instantiate the API \WPackio\Enqueue.


Start development server

npm start
Or if using yarn

yarn start
This will start the development server proxying your local WordPress server. Now you can have access to hot module replacement and live file watching. Just edit your files and see it live in the browser.

In the image, we see changing the heading is seen live in the browser. It is done through react-hot-loader. Do check out advanced concepts to learn how we have set that up.

Once done, press Ctrl + c to stop the server.


Build Production files

npm run build
Or if using yarn

yarn build
Now create production builds with this single command. By default @wpackio/scripts will optimize build, minify output and create source-maps in different files.


Create distributable zip file

npm run archive
Or if using yarn

yarn archive
You may now want to create an installable .zip file for your theme or plugin. @wpackio/scripts makes it easy with one single command. Use it to readily deploy your plugin or theme to WordPress.org repository or to your server.