webpack 安装步骤

  1. 安装nodejs

  2. 全局安装 webpack

npm install -g webpack
  1. 初始化项目
npm init --yes
webpack 安装步骤_第1张图片
目录结构
  1. 安装webpack-dev-server
npm install webpack-dev-server --save-dev
npm install webpack --save-dev
  1. 安装 loader
npm install css-loader style-loader --save-dev
npm install less less-loader --save-dev
npm install babel-core babel-loader babel-preset-es2015 --save-dev
  1. package.json
{
  "name": "es6",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "pack": "webpack",
    "dev": "webpack-dev-server --hot --inline"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.24.1",
    "babel-loader": "^7.0.0",
    "babel-preset-es2015": "^6.24.1",
    "css-loader": "^0.28.4",
    "less": "^2.7.2",
    "less-loader": "^4.0.4",
    "style-loader": "^0.18.1",
    "webpack": "^2.6.1",
    "webpack-dev-server": "^2.4.5"
  }
}
  1. webpack.config.js
webpack 安装步骤_第2张图片
image.png
  1. main.js
webpack 安装步骤_第3张图片
image.png
  1. cats.js
webpack 安装步骤_第4张图片
image.png
  1. modules.js
webpack 安装步骤_第5张图片
image.png
  1. less/base.less
webpack 安装步骤_第6张图片
image.png
  1. style/index.css
webpack 安装步骤_第7张图片
image.png
  1. index.html
webpack 安装步骤_第8张图片
image.png

你可能感兴趣的:(webpack 安装步骤)