forked from jaketrent/html-webpack-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ejs
101 lines (82 loc) · 4.14 KB
/
index.ejs
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<% var item, key %>
<% htmlWebpackPlugin.options.appMountIds = htmlWebpackPlugin.options.appMountIds || [] %>
<% htmlWebpackPlugin.options.lang = htmlWebpackPlugin.options.lang || "en" %>
<% htmlWebpackPlugin.options.links = htmlWebpackPlugin.options.links || [] %>
<% htmlWebpackPlugin.options.meta = htmlWebpackPlugin.options.meta || [] %>
<% htmlWebpackPlugin.options.scripts = htmlWebpackPlugin.options.scripts || [] %>
<!DOCTYPE html>
<html lang="<%= htmlWebpackPlugin.options.lang %>" <% if (htmlWebpackPlugin.files.manifest) { %> manifest="<%= htmlWebpackPlugin.files.manifest %>"<% } %>>
<head>
<meta charset="utf-8">
<meta content="ie=edge" http-equiv="x-ua-compatible">
<% if (htmlWebpackPlugin.options.baseHref) { %>
<base href="<%= htmlWebpackPlugin.options.baseHref %>">
<% } %>
<% if (Array.isArray(htmlWebpackPlugin.options.meta)) { %>
<% for (item of htmlWebpackPlugin.options.meta) { %>
<meta<% for (key in item) { %> <%= key %>="<%= item[key] %>"<% } %>>
<% } %>
<% } %>
<title><%= htmlWebpackPlugin.options.title %></title>
<% if (htmlWebpackPlugin.files.favicon) { %>
<link href="<%= htmlWebpackPlugin.files.favicon %>" rel="shortcut icon">
<% } %>
<% if (htmlWebpackPlugin.options.mobile) { %>
<meta content="width=device-width, initial-scale=1" name="viewport">
<% } %>
<% for (item of htmlWebpackPlugin.options.links) { %>
<% if (typeof item === 'string' || item instanceof String) { item = { href: item, rel: 'stylesheet' } } %>
<link<% for (key in item) { %> <%= key %>="<%= item[key] %>"<% } %>>
<% } %>
<% for (key in htmlWebpackPlugin.files.css) { %>
<link href="<%= htmlWebpackPlugin.files.css[key] %>" rel="stylesheet">
<% } %>
</head>
<body>
<% if (htmlWebpackPlugin.options.unsupportedBrowser) { %>
<style>.unsupported-browser { display: none; }</style>
<div class="unsupported-browser">
Sorry, your browser is not supported. Please upgrade to the latest version or switch your browser to use this
site. See <a href="http://outdatedbrowser.com/">outdatedbrowser.com</a> for options.
</div>
<% } %>
<% if (htmlWebpackPlugin.options.appMountId) { %>
<div id="<%= htmlWebpackPlugin.options.appMountId %>"></div>
<% } %>
<% for (item of htmlWebpackPlugin.options.appMountIds) { %>
<div id="<%= item %>"></div>
<% } %>
<% if (htmlWebpackPlugin.options.window) { %>
<script type="text/javascript">
<% for (key in htmlWebpackPlugin.options.window) { %>
window['<%= key %>'] = <%= JSON.stringify(htmlWebpackPlugin.options.window[key]) %>;
<% } %>
</script>
<% } %>
<% if (htmlWebpackPlugin.options.inlineManifestWebpackName) { %>
<%= htmlWebpackPlugin.files[htmlWebpackPlugin.options.inlineManifestWebpackName] %>
<% } %>
<% for (item of htmlWebpackPlugin.options.scripts) { %>
<% if (typeof item === 'string' || item instanceof String) { item = { src: item, type: 'text/javascript' } } %>
<script<% for (key in item) { %> <%= key %>="<%= item[key] %>"<% } %>></script>
<% } %>
<% for (key in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[key].entry %>" type="text/javascript"></script>
<% } %>
<% if (htmlWebpackPlugin.options.devServer) { %>
<script src="<%= htmlWebpackPlugin.options.devServer %>/webpack-dev-server.js" type="text/javascript"></script>
<% } %>
<% if (htmlWebpackPlugin.options.googleAnalytics) { %>
<script type="text/javascript">
window.GoogleAnalyticsObject='ga';window.ga=function(){ga.q.push(arguments)};ga.q=[];ga.l=+new Date;
<% if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
ga('create','<%= htmlWebpackPlugin.options.googleAnalytics.trackingId %>','auto');
<% } else { throw new Error("html-webpack-template requires googleAnalytics.trackingId config"); } %>
<% if (htmlWebpackPlugin.options.googleAnalytics.pageViewOnLoad) { %>
ga('send','pageview')
<% } %>
</script>
<script async defer src="https://www.google-analytics.com/analytics.js" type="text/javascript"></script>
<% } %>
</body>
</html>