From the course: Learning webpack 4

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Run the build with webpack.config

Run the build with webpack.config

From the course: Learning webpack 4

Start my 1-month free trial

Run the build with webpack.config

- At the root of our project we want to create a file called webpack.config.js. So we're going to add this to our start file, webpack.config.js. Now this is going to set up all of our configuration options for webpack so that we don't have to manually type commands. The first thing that we're going to add is the path module from note.js, and this is going to help us route our created files into the proper directory. We then are going to use module.exports, we'll set up an entry point, the entry point is just our main JavaScript file so at this point is index.js inside of our source. So we'll say ./src/index.js, we also will specify an output and this is going to be the file name main.js, and the path, path.resolve, we want to look for the dirname dist for our output. Now if you still have your main .js file in your disk folder you want to delete it just to make sure this is working as expected. Alright, so to run webpack let's run npx webpack. This is going to generate that main .js…

Contents