UNPKG

1.02 kBJavaScriptView Raw
1var createElement = function() {
2 var div = document.createElement("div");
3 var style = {
4 background: "#0baa23",
5 color: "white",
6 padding: "2px 4px",
7 display: "inline-block",
8 position: "fixed",
9 right: "0",
10 bottom: "0",
11 fontSize: "12px"
12 };
13 for (var key in style) {
14 div.style[key] = style[key];
15 }
16 return div;
17};
18
19var handler = {
20 development: function() {
21 document.addEventListener(
22 "DOMContentLoaded",
23 function() {
24 var div = createElement();
25 var time = window.WEBPACK_BUILD_TIME;
26 div.textContent = time;
27 document.body.appendChild(div);
28 },
29 false
30 );
31 },
32 production: function() {
33 document.addEventListener(
34 "DOMContentLoaded",
35 function() {
36 var time = window.WEBPACK_BUILD_TIME;
37 console.log(
38 "%c BUILD TIME : " + time,
39 "font-weight:bold;background:green;color:white;padding:2px 4px;"
40 );
41 },
42 false
43 );
44 }
45};
46
47handler[process.env.NODE_ENV]();