I need help setting up Hot Module Reloading with Webpack and Shopify ThemeKit. Using Webpack Shell Plugin Next I am trying to execute the following steps.
- Start Webpack and Watch for Changes
- Build TailwindCSS
- Deploy Theme
- Open Theme
- Watch Theme for Changes
Here is my current setup which does not trigger a rebuild on file change and saves for hot module reloading.
package.json
"scripts": {
"start": "NODE_ENV=development webpack --watch"
},
webpack.config.js
// Run Shell commmands during Webpack operations
if (mode === 'development') {
module.exports.plugins.push(
new WebpackShellPluginNext({
onBuildStart:{
scripts: ['echo -- Webpack build started '],
blocking: true,
parallel: false
},
onBuildError:{
scripts: ['echo -- ☠️ Aw snap, Webpack build failed...'],
},
onBuildEnd:{
scripts: [
'echo -- Webpack build complete ✓',
'echo -- Building TailwindCSS...',
'npx tailwindcss build src/components/tailwind.css -o dist/assets/tailwind.css.liquid',
'echo -- Deploying to theme ✈️',
'shopify-themekit deploy',
'echo -- Deployment competed ✓',
'shopify-themekit open',
'shopify-themekit watch'],
blocking: true,
parallel: false
}
})
)
}
The current setup builds and deploys correctly but there is no reloading when changing and saving files. I tried various order of operations and api's from the Webpack Shell Plugin Next but I am stuck to find the right combination.
Here is a link to the full repo: Shopify ThemeKit with Webpack 4