看看webpack官网, 比installation章节, 面介绍安装webpack.
首先需要安装全局webpack
npm install webpack -g
才确使用webpack命令
, 前项目面安装webpack, 官推荐做
npm install webpack --save-dev
自webpack.config.js面便引用webpack
// webpack.config.js
var path = require('path');
var webpack = require('webpack');
使用些plugin候比较便
new webpack.optimize.CommonsChunkPlugin('common.js')