Why is "dist/main.js" created only with the codes in my index.js file but not more when I use Webpack?

106 Views Asked by At

I was watching a Webpack tutorial to understand the concept of it and when I was following the tutorial some didn't result in the same way.

My package.json folder is like this:

 {
  "name": "code",
  "version": "1.0.0",
  "private": "true",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^5.89.0",
    "webpack-cli": "^5.1.4"
  }

My index.js file in src is just an alert function and that's all.

alert("HELLO FROM WEBPACK");

So in the tutorial when he ran "npm start" a "dist/main.js" folder was created in main.js and There were a bunch of codes in it.

But when I did the same and in the main.js there was only the code that wrote in the index.js.

So this tutorial was four years ago. Is something changed and this is completely normal or is there a problem with it?

1

There are 1 best solutions below

1
On

Most likely, the man in the tutorial had a webpack.config.js, which influenced the build. If you don't have the config, then by default there will be a build with mode "production" and such an output is ok.