How webpack.config.js work in react project?

689 Views Asked by At

I saw react + express project code here, start project just using this codes.

  • rm -rf build public/bundle.js
  • ./node_modules/.bin/babel server --out-dir build
  • ./node_modules/.bin/webpack --progress
  • node ./build/main.js"

But I can't find how to read/execute webpack.config.js command. Who read this code? and how it works?

2

There are 2 best solutions below

2
On BEST ANSWER

Webpack reads webpack.config.js by default, unless you explicitly tell it to read another config file by using the --config argument, e.g.:

webpack --config another.config.js

In your case, this command reads the webpack.config.js:

./node_modules/.bin/webpack --progress
0
On

You don't execute webpack.config.js. It is a configuration file that webpack will refer to and use when webpack is run. See this page for more info.

The build and start scripts in the package.json file for the project you linked to both run webpack. Webpack will then create a bundle.js file according to the information in webpack.config.js.