Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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:

  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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(