Skip to content
This repository was archived by the owner on Jul 19, 2021. It is now read-only.

Commit 7b29465

Browse files
authored
Merge pull request #808 from tshamz/support-customers-level-template-bundles
Support customers level template bundles
2 parents 91030c9 + 2ea4f4f commit 7b29465

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

packages/slate-tools/tools/webpack/config/utilities/get-template-entrypoints.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ module.exports = function() {
5858
'customers',
5959
`${name}.js`,
6060
);
61-
if (VALID_LIQUID_TEMPLATES.includes(name) && fs.existsSync(jsFile)) {
61+
62+
if (isValidTemplate(name) && fs.existsSync(jsFile)) {
6263
entrypoints[`template.${name}`] = jsFile;
6364
}
6465
});

packages/slate-tools/tools/webpack/script-tags.html

+18-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818

1919
<% pages.forEach(function(page){ %>
2020
<% if (typeof htmlWebpackPlugin.options.liquidTemplates[page] !== 'undefined') { %>
21-
<% conditions.push("template == '" + page.split('.').slice(1).join('.') + "'") %>
21+
<% if (htmlWebpackPlugin.options.liquidTemplates[page].includes('customers/')) { %>
22+
<% conditions.push("template == 'customers/" + page.split('.').slice(1).join('.') + "'") %>
23+
<% } else { %>
24+
<% conditions.push("template == '" + page.split('.').slice(1).join('.') + "'") %>
25+
<% } %>
2226
<% } else if (typeof htmlWebpackPlugin.options.liquidLayouts[page] !== 'undefined') { %>
2327
<% conditions.push("layout == '" + page.split('.')[1] + "'") %>
2428
<% } %>
@@ -30,11 +34,19 @@
3034
<link rel="prefetch" href="<%= src %>" as="script">
3135
{%- endif -%}
3236
<% } else if (typeof htmlWebpackPlugin.options.liquidTemplates[chunk] !== 'undefined') { %>
33-
{%- if template == '<%= chunk.split('.').slice(1).join('.') %>' -%}
34-
<script type="text/javascript" src="<%= src %>" defer></script>
35-
{%- else -%}
36-
<link rel="prefetch" href="<%= src %>" as="script">
37-
{%- endif -%}
37+
<% if (htmlWebpackPlugin.options.liquidTemplates[chunk].includes('customers/')) { %>
38+
{%- if template == 'customers/<%= chunk.split('.').slice(1).join('.') %>' -%}
39+
<script type="text/javascript" src="<%= src %>" defer></script>
40+
{%- else -%}
41+
<link rel="prefetch" href="<%= src %>" as="script">
42+
{%- endif -%}
43+
<% } else { %>
44+
{%- if template == '<%= chunk.split('.').slice(1).join('.') %>' -%}
45+
<script type="text/javascript" src="<%= src %>" defer></script>
46+
{%- else -%}
47+
<link rel="prefetch" href="<%= src %>" as="script">
48+
{%- endif -%}
49+
<% } %>
3850
<% } else { %>
3951
<script type="text/javascript" src="<%= src %>" defer></script>
4052
<% } %>

packages/slate-tools/tools/webpack/style-tags.html

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<% for (var css in htmlWebpackPlugin.files.css) { %>
32
<% var basename = htmlWebpackPlugin.files.css[css].split('/').reverse()[0]; %>
43
<% var chunkName = basename.replace('.scss', '').replace('.css', '').replace('.styleLiquid', ''); %>
@@ -8,11 +7,19 @@
87
<% var src = `{{ '${basename}' | asset_url }}` %>
98

109
<% if (typeof htmlWebpackPlugin.options.liquidTemplates[chunkName] !== 'undefined') { %>
11-
{%- if template == '<%= chunkName.split('.').slice(1).join('.') %>' -%}
12-
<link type="text/css" href="<%= src %>" rel="stylesheet">
13-
{%- else -%}
14-
<link rel="prefetch" href="<%= src %>" as="style">
15-
{%- endif -%}
10+
<% if (htmlWebpackPlugin.options.liquidTemplates[chunkName].includes('customers/')) { %>
11+
{%- if template == 'customers/<%= chunkName.split('.').slice(1).join('.') %>' -%}
12+
<link type="text/css" href="<%= src %>" rel="stylesheet">
13+
{%- else -%}
14+
<link rel="prefetch" href="<%= src %>" as="style">
15+
{%- endif -%}
16+
<% } else { %>
17+
{%- if template == '<%= chunkName.split('.').slice(1).join('.') %>' -%}
18+
<link type="text/css" href="<%= src %>" rel="stylesheet">
19+
{%- else -%}
20+
<link rel="prefetch" href="<%= src %>" as="style">
21+
{%- endif -%}
22+
<% } %>
1623
<% } else if (typeof htmlWebpackPlugin.options.liquidLayouts[chunkName] !== 'undefined') { %>
1724
{%- if layout == '<%= chunkName.split('.')[1] %>' -%}
1825
<link type="text/css" href="<%= src %>" rel="stylesheet">
@@ -25,7 +32,11 @@
2532

2633
<% pages.forEach(function(page){ %>
2734
<% if (typeof htmlWebpackPlugin.options.liquidTemplates[page] !== 'undefined') { %>
28-
<% conditions.push("template == '" + page.split('.').slice(1).join('.') + "'") %>
35+
<% if (htmlWebpackPlugin.options.liquidTemplates[page].includes('customers/')) { %>
36+
<% conditions.push("template == 'customers/" + page.split('.').slice(1).join('.') + "'") %>
37+
<% } else { %>
38+
<% conditions.push("template == '" + page.split('.').slice(1).join('.') + "'") %>
39+
<% } %>
2940
<% } else if (typeof htmlWebpackPlugin.options.liquidLayouts[page] !== 'undefined') { %>
3041
<% conditions.push("layout == '" + page.split('.')[1] + "'") %>
3142
<% } %>

0 commit comments

Comments
 (0)