webpack-lazyload
v0.0.3
Published
Utility function that allows to attach webpack bundle to your application on demand
Downloads
2
Readme
webpack-lazyload
Utility function that allows to attach webpack bundle to your application on demand.
Setup
Your application should use webpack and have entry point exported as webpack library:
webpack.config.js:
module.exports = {
...
entry: './entry.js',
output: {
...,
library: ['lazyload', 'bundleID'], // bundleID - some identificator of your bundled application
libraryTarget: 'assign',
...
},
...
entry.js:
...
import root from './root.js'; // your bundle's entrypoint
const node = document.getElementById('someuniqid'); // someuniqid should be different from bundleID
if (node) {
...
ReactDOM.render(root, node);
...
}
export default root; // let the webpack to export a pointer to bundle's entrypoint