Search code examples
webpackwebpack-dev-server

How to detect if webpack-dev-server is running?


How can I determine if webpack.config.js was loaded via webpack vs webpack-dev-server?


Solution

  • Update: The environment variable is changed to WEBPACK_SERVE.

    The webpack dev server will now set the WEBPACK_DEV_SERVER environment variable, allowing for a more robust way to check.

    const isDevServer = process.env.WEBPACK_DEV_SERVER;