New Metronic Docs!Added Integration Docs with Starter Kits Apps for Laravel, Laravel Livewire, Angular, Vue, Symfony, Blazor Server, Django & Flask & more
Browse Docs

Webpack Build Hangs Indefinitely in Development Mode


## Environment
- OS: macOS
- Metronic Version: 9.3.4
- Webpack: 5.99.9

## Description
The webpack build process hangs indefinitely and never completes when running `npm run build:js` or `npm run build`.

## Root Cause
Two configuration issues in [webpack.config.js](/metronic/webpack.config.js:0:0-0:0):

1. Duplicate CSS loader rules (lines 174-181): Two conflicting rules for `.css` files cause webpack to hang
2. Watch mode always enabled (line 134): `watch: true` hardcoded for development mode prevents build from completing

## Steps to Reproduce
1. Clone/install Metronic 9.3.4
2. Run `npm run build:js`
3. Build hangs indefinitely with no output or completion

## Fix Applied

### 1. Make watch mode configurable (line 134):

Before:
watch: env.production ? false : true,

After:
watch: env.watch || false,


### 2. Remove duplicate CSS loader (lines 174-181):

Before (two conflicting rules):
{
test: /\.css$/i,
use: ["style-loader", "css-loader", "postcss-loader"],
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"],
},

After (single rule):
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"],
}


### 3. Add watch script to package.json:

"scripts": {
"build:js": "webpack --mode=development",
"build:js:watch": "webpack --mode=development --env watch",
...
}


## Result
- npm run build:js - Completes successfully in ~1.7s
- npm run build:js:watch - Runs in watch mode for development
- npm run build:prod - Completes successfully in ~4.3s

## Recommendation
The default `build:js` command should complete and exit (for CI/CD), with a separate `build:js:watch` command for development file watching, matching the pattern already used for CSS (`build:css` vs `build:css:watch`).


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi

Thank you for your feedback. We will improve it.

You can use "npm run build:prod" to build without watch mode.

Thanks


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(