Previous 7 Next

NPM

Node.js package manager (NPM) manages the external libraries we use for development. We configure our project by creating a package.json file that declares the project's dependencies and scripts that we can call from the command line.

package.json
{
  "scripts": {
    "start": "webpack-dev-server --config webpack.ts --devtool source-map",
    "build": "webpack --config webpack.ts --mode=production"
  },
  "dependencies": {
    "@types/html-webpack-plugin": "3.2.0",
    "@types/webpack": "4.4.33",
    "clean-webpack-plugin": "3.0.0",
    "file-loader": "4.0.0",
    "html-webpack-plugin": "3.2.0",
    "ts-loader": "6.0.4",
    "typescript": "3.5.2",
    "webpack": "4.35.0",
    "webpack-cli": "3.3.5",
    "webpack-dev-server": "3.7.2"
  }
}

Scripts

start

Starts the development server which will build the game and reload the browser whenever we change the code.

npm run start

build

Builds the game and bundles all the assets into a folder that can be deployed.

npm run build

Dependencies

Declares packages needed to setup TypeScript and webpack for development.

Links

Previous 7 Next