webpack notes

By Xah Lee. Date: .

create a dir, go into it

mkdir webpack_study
cd webpack_study

run this to create a init npm project.

npm init -y

the -y means just use default values, instread of asking at prompt.

it creates a file named package.json

the file looks like this:

{
  "name": "webpack_study",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

install webpack:

npm install webpack --save-dev

the --save-dev means save as a dev dependency. dev dependency means this packages is used for dev purposes, and is not part of your final software.

now, install webpack-cli, which is command line util.

npm install webpack-cli --save-dev

now the package.json looks like this:

{
  "name": "webpack_study",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {},
  "devDependencies": {
    "webpack": "^4.41.2",
    "webpack-cli": "^3.3.9"
  }
}

If you have a question, put $5 at patreon and message me.

webdev

  1. main