-
Notifications
You must be signed in to change notification settings - Fork 0
installation.cn
Install node.js.
安装node.js
node.js comes with a package manager called npm.
node.js 内置了一个叫做 npm 的包管理工具。
webpack can be installed through npm:
可以通过 npm 安装 webpack:
$ npm install webpack -gwebpack is now installed globally and the webpack command is available.
这样,webpack 将被安装为全局工具,同时,也提供了一个 webpack 的命令。
It's the best to have webpack also as dependency in your project. Through this you can choose a local webpack version and will not be forced to use the single global one.
最佳实践是把 webpack 也作为项目的依赖。这样,每个项目都可以使用自己所需要的版本,而不必依赖于全局的 webpack。
Add a package.json configuration file for npm with:
通过 npm 来增加一个 package.json 文件:
$ npm initThe answers to the questions are not so important if you don't want to publish your project to npm.
[上面这一句可能是从SO复制过来的,所以对此话题貌似无意义]
Install and add webpack to the package.json with:
用下面的命令安装 webpack 并将其添加到 packeage.json 中:
$ npm install webpack --save-devThere are two versions of webpack available. The stable one and a beta version. The beta version is marked with a -beta in the version string. The beta version may contain fragile changes or experimental features and is less tested. See changelog for differences. For serious stuff you should use the stable version:
webpack 有稳定版和 beta 版两个可用的版本,其中,beta 版本在版本号中添加了 -beta 的标识。beta 版本可能带有很多不稳定更新或实验性的功能,并且未完全测试。可查看changelog来看各版本的差别。正式项目中应该使用稳定版本。
$ npm install [email protected] --save-devIf you want to use dev tools you should install it:
如果想使用开发工具,需要安装 webpack-dev-server
$ npm install webpack-dev-server --save-devYou can continue reading Usage.
更多可阅读Usage
此篇翻译参照了liunian/webpack-doc对应的文档