Use Webpack with HMR in your WordPress theme.
This WordPress starter theme demonstrates the use of Webpack for compiling assets during development. It includes the use of Bootstrap 4's SCSS components and features hot module replacement. HMR is triggered by changes to the source JS and CSS files.
Usage
- Install the theme as you would normally install a WordPress theme
-
Install dependencies with yarn or npm
> npm install
> # or
> yarn install
-
Set WP_ENVIRONMENT to "development" in wp-config.php
define('WP_ENVIRONMENT', 'development');
-
Start up webpack in the terminal and watch for changes:
> npm run dev
-
When you are ready to deploy to production, build assets:
> npm run build