mirror of https://github.com/webpack/webpack.git
24 lines
871 B
JavaScript
24 lines
871 B
JavaScript
|
var render = require("./render");
|
||
|
|
||
|
// Event when another page should be opened
|
||
|
// Maybe hook click on links, hashchange or popstate
|
||
|
window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
|
||
|
// require the page with a dynamic require
|
||
|
|
||
|
// It's important that this require only matches the pages
|
||
|
// elsewise there is blood in the bundle. Here this is done with a
|
||
|
// specific file prefix. It's also possible to use a directory,
|
||
|
// overwriting the RegExp with the ContextReplacementPlugin, or
|
||
|
// using the require.context method.
|
||
|
|
||
|
// The bundle-loader is used to create a chunk from the page
|
||
|
// -> Pages are only loaded on demand
|
||
|
|
||
|
// This line may throw a exception on runtime if the page wasn't found.
|
||
|
var pageBundle = require("bundle!./" + name + "Page");
|
||
|
|
||
|
// Wait until the chunk is loaded
|
||
|
pageBundle(function(page) {
|
||
|
render(page);
|
||
|
});
|
||
|
}
|