Skip to content

Instantly share code, notes, and snippets.

@tivac

tivac/index.html Secret

Last active February 26, 2018 06:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tivac/d5ad2e548a97fac7152ca827b0d07c8b to your computer and use it in GitHub Desktop.
Save tivac/d5ad2e548a97fac7152ca827b0d07c8b to your computer and use it in GitHub Desktop.
Rollup + Mithril w/ code-splitting
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Rollup code-splitting</title>
</head>
<body>
<script src="node_modules/systemjs/dist/system.js"></script>
<script src="node_modules/mithril/mithril.js"></script>
<script src="dist/index.js"></script>
<script>SystemJS.import("./dist/index.js")</script>
</body>
</html>
/* global m */
m.route(document.body, "/", {
"/" : {
view : () => m("div", "HOME",
m("p",
m("a", { href : "/page", oncreate : m.route.link }, "/page")
)
)
},
"/page" : {
onmatch : () => {
return import("./page.js").then((page) => page.default);
}
}
});
{
"name": "rollup-splitting",
"version": "1.0.0",
"main": "index.js",
"devDependencies": {
"mithril": "^1.1.6",
"rollup": "^0.55.0",
"rollup-plugin-serve": "^0.4.2",
"systemjs": "^0.20.19"
}
}
/* global m */
export default {
view : () => m("div", "/page!")
};
module.exports = {
input : [ "./index.js" ],
output : {
dir : "./dist",
format : "system",
},
experimentalCodeSplitting: true,
experimentalDynamicImport: true,
plugins : [
require("rollup-plugin-serve")({
port : 10002,
contentBase : "./"
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment