- 关于文档
- 1. 概览
- 开始
- 2.1. 动机
- 2.2. webpack是什么
- 2.3. 安装
- 2.4. 用法
- 2.5. Require Modules
- 2.6. Vendor Modules
- 2.7. 使用 Loaders
- 2.8. 使用 Plugins
- 2.9. 工具
- 2.10. 故障处理
- 教程与例子
- 指南
- webpack with
- Lists
- Development
- 7.1. Changelog
- 7.2. Roadmap
- 7.3. Ideas
- 7.4. Contributing
- Published with GitBook
webpack doc
Installation
Installation is via npm:
npm install webpack -g
Compiling JavaScript
Give Webpack an entry point and an output file:
webpack ./app.js app.bundle.js
Creating a JavaScript module
We can define modules in JavaScript using the CommonJS syntax, as for Node:
cats.js
var cats = ['dave', 'henry', 'martha'];
module.exports = cats;
app.js
cats = require('./cats.js');
console.log(cats);
FURTHER READING
Recommended reading: Webpack your bags by Maxime Fabre - a very good introduction on how to setup a real-world project using Webpack.
- see [[CLI]] for the command line interface.
- see [[node.js API]] for the node.js interface.
- see [[Configuration]] for the configuration options.