Skip to content

Commit 4092581

Browse files
fix: assets linking
1 parent 9aab6ab commit 4092581

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

apps/bolt-site/.boltrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,10 @@ module.exports = {
6666
],
6767
individual: [],
6868
},
69+
extraTwigNamespaces: {
70+
'bolt-assets': {
71+
recursive: true,
72+
paths: ['../../www/build'],
73+
},
74+
},
6975
};

apps/bolt-site/templates/template-index.twig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
{% set hasSidebar = nestedPages or sidebar %}
1313
{# End Global Twig vars #}
1414

15+
{% set manifestConfigFile = "@bolt-assets/bolt-webpack-manifest#{bolt.data.config.lang ? "-" ~ bolt.data.config.lang[0] : ""}.json" %}
16+
{% if fileExists(manifestConfigFile) %}
17+
{% set assets = get_data(manifestConfigFile) %}
18+
{% else %}
19+
{% set assets = [] %}
20+
{% endif %}
21+
1522

1623
<!DOCTYPE html>
1724
<html lang="en-US" class="{{ bolt.data.config.prod ? '' : 'js-fonts-loaded' }}">
@@ -37,10 +44,10 @@
3744

3845
<!-- async load PL's CSS -->
3946
<link rel="preload" href="/pattern-lab/styleguide/css/pattern-lab.css" as="style" onload="this.rel='stylesheet'">
40-
<link rel="stylesheet" href="{{ assets["bolt-global.css"] | default("/pattern-lab/build/bolt-global.css") }}" media="all" />
41-
47+
<link rel="preload" as="style" href="{{ assets["bolt-global.css"] | default("/build/bolt-global.css") }}" onload="this.onload=null;this.rel='stylesheet'" />
4248
<noscript>
4349
<link href="/pattern-lab/styleguide/css/pattern-lab.css" rel="stylesheet">
50+
<link rel="stylesheet" href="{{ assets["bolt-global.css"] | default("/build/bolt-global.css") }}" />
4451
</noscript>
4552

4653

@@ -156,5 +163,6 @@
156163
})();
157164
</script>#}
158165
{% endif %}
166+
<script src="{{ assets["bolt-global.js"] | default("/build/bolt-global.js") }}" async></script>
159167
</body>
160168
</html>

0 commit comments

Comments
 (0)