当前位置:  首页>> 技术小册>> webpack指南

经过前面非模块化和AMD打包的例子,本节我们就不再绕圈子,直接看例子。

HTML代码和之前仍然是一样的,不再重复,JS文件如下:

入口文件example1.1.js

  1. var example2 = require('./example1.2');
  2. example2.sayHello();

被依赖的example1.2.js

  1. var me = {
  2. sayHello:function(){
  3. alert('hello world!');
  4. }
  5. };
  6. module.exports = me;

同样使用webpack编译就能看到相同的弹窗。


该分类下的相关小册推荐: