forked from webpack-contrib/mini-css-extract-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (21 loc) · 856 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import './initial.css';
const handleError = (err) => {
document.querySelector(".errors").textContent += `\n${err.toString()}`;
console.error(err);
}
const makeButton = (className, fn, shouldDisable = true) => {
const button = document.querySelector(className);
button.addEventListener("click", () => {
if(shouldDisable) {
button.disabled = true;
}
fn().then(() => {
button.disabled = false;
}).catch(handleError);
});
}
makeButton(".lazy-button", () => import('./lazy.js'));
makeButton(".lazy-button2", () => import('./lazy2.css'));
makeButton(".preloaded-button1", () => import(/* webpackChunkName: "preloaded1" */ './preloaded1'));
makeButton(".preloaded-button2", () => import(/* webpackChunkName: "preloaded2" */ './preloaded2'));
makeButton(".lazy-failure-button", () => import('./lazy-failure.js'), false);