How to specify webpack-dev-server webpack.config.js file location

21,037

Solution 1

Just came across this issue. As spacek33z said, --config is correct. I couldn't find this in the webpack docs or the webpack-dev-server docs, so I found myself at this question.

e.g.

webpack-dev-server --config demo/webpack.config.js

Solution 2

For newbies like me:

Mention the config path in package.json similar to below:

{
  "name": "abc",

  "version": "0.0.1",

  "description": "description",

  "main": "index.js",

  "scripts": {
    "dev": "webpack-dev-server --config ./client/webpack.config.js",
    "build": "webpack --config ./client/webpack.config.js"
   }
}
Share:
21,037

Related videos on Youtube

Mayday
Author by

Mayday

I'm a software engineer.

Updated on January 03, 2020

Comments

  • Mayday
    Mayday over 4 years

    I am starting with webpack.

    I have been able to specify to webpack the location of webpack.config.js like this:

    "webpack --config ./App/webpack.config.js"
    

    Now I am trying to use the webpack-dev-server with that file also, but I can not find how to specify the webpack.config.js location to it.

    This is the relevant part of my package.json

    "scripts": {
      "start": "webpack-dev-server --config ./App/webpack.config.js --progress --colors",
      "build": "webpack --config ./App/webpack.config.js --progress --colors"
    }
    

    How can I pass the ./App/ directory to my webpack-dev-server?

    • spacek33z
      spacek33z over 7 years
      Using --config should work. What error do you get?
  • Iago Barreto
    Iago Barreto over 3 years
    Can you add a configuration file example? as webpack.config.js