目录
Webpack 2.2 中文文档
bundle-loader
webpack 的文件束加载器bundle-loader
Usage
// 当你引用 文件束 (bundle) 的时候,chunk 会被浏览器加载。 var waitForChunk = require("bundle-loader!./file.js"); // 为了等待 chunk 的加载完成 (而且为了拿到 exports 输出) // 你需要异步去等待它 waitForChunk(function(file) { // 这里可以使用file,就像是用下面的代码require进来一样 // var file = require("./file.js"); }); // 将 require 包裹在 require.ensure 的代码块中
当你引用文件束的时候,chunk 会被浏览器加载。如果你想它懒加载,请用:
var load = require("bundle-loader?lazy!./file.js"); // 文件束不会被加载,除非你调用了 call 函数 load(function(file) { });
你可能会给文件束设名称(name 查询参数)。请查看documentation.
require("bundle-loader?lazy&name=my-chunk!./file.js");
License
MIT (http://www.opensource.org/licenses/mit-license.php)
原文:https://webpack.js.org/loaders/bundle-loader/
上一篇: babel-loader 下一篇: coffee-loader