Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 324
Mayday Avatar asked Sep 07 '16 11:09

Mayday


People also ask

Where is my webpack config js file?

The easiest way to get your webpack. config. js file to work is to place it at the top level of your project's folder structure along with your package.

Where does webpack-dev-server store files?

By default, webpack-dev-server serves the config's output. filename on localhost:8080/ (eg. localhost:8080/bundle. js ).

What is webpack public path?

publicPath specifies the virtual directory in web server from where bundled file, app. js is going to get served up from. Keep in mind, the word server when using publicPath can be either webpack-dev-server or express server or other server that you can use with webpack.


2 Answers

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

like image 177
3stacks Avatar answered Sep 25 '22 02:09

3stacks


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"    } } 
like image 20
Razi Abdul Rasheed Avatar answered Sep 26 '22 02:09

Razi Abdul Rasheed