@@ -20,6 +20,8 @@ const dedent = require("dedent");
20
20
//
21
21
// Paths for various assets (sources and destinations)
22
22
//
23
+
24
+ const scriptPath = resolve ( __dirname , "src/pydata_sphinx_theme/assets/scripts" ) ;
23
25
const staticPath = resolve (
24
26
__dirname ,
25
27
"src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static"
@@ -36,10 +38,24 @@ const vendorPaths = {
36
38
// Cache-busting Jinja2 macros (`webpack-macros.html`) used in `layout.html`
37
39
//
38
40
function macroTemplate ( { compilation } ) {
41
+ // add a hash keep for each build
39
42
const hash = compilation . hash ;
43
+
40
44
// We load these files into the theme via HTML templates
41
- const css_files = [ "styles/theme.css" , "styles/pydata-sphinx-theme.css" ] ;
42
- const js_files = [ "scripts/pydata-sphinx-theme.js" ] ;
45
+ const css_files = [
46
+ "styles/theme.css" , // basic sphinx css
47
+ "styles/bootstrap.css" , // all bootstrap 5 css with variable adjustments
48
+ "styles/pydata-sphinx-theme.css" , // all the css created for this specific theme
49
+ ] ;
50
+ const js_files = [ "scripts/bootstrap.js" , "scripts/pydata-sphinx-theme.js" ] ;
51
+ const icon_files = [
52
+ `vendor/fontawesome/${ vendorVersions . fontAwesome } /webfonts/fa-solid-900.woff2` ,
53
+ `vendor/fontawesome/${ vendorVersions . fontAwesome } /webfonts/fa-brands-400.woff2` ,
54
+ `vendor/fontawesome/${ vendorVersions . fontAwesome } /webfonts/fa-regular-400.woff2` ,
55
+ ] ;
56
+ const font_files = [
57
+ `vendor/fontawesome/${ vendorVersions . fontAwesome } /css/all.min.css` ,
58
+ ] ;
43
59
44
60
// Load a CSS script with a digest for cache busting.
45
61
function stylesheet ( css ) {
@@ -56,29 +72,20 @@ function macroTemplate({ compilation }) {
56
72
return `<script src="{{ pathto('_static/${ js } ', 1) }}?digest=${ hash } "></script>` ;
57
73
}
58
74
75
+ // Load the fonts as preload files
76
+ function font ( woff2 ) {
77
+ return `<link rel="preload" as="font" type="font/woff2" crossorigin href="{{ pathto('_static/${ woff2 } ', 1) }}">` ;
78
+ }
79
+
59
80
return dedent ( `\
60
81
<!--
61
82
AUTO-GENERATED from webpack.config.js, do **NOT** edit by hand.
62
83
These are re-used in layout.html
63
84
-->
64
85
{# Load FontAwesome icons #}
65
86
{% macro head_pre_icons() %}
66
- <link rel="stylesheet"
67
- href="{{ pathto('_static/vendor/fontawesome/${
68
- vendorVersions . fontAwesome
69
- } /css/all.min.css', 1) }}">
70
- <link rel="preload" as="font" type="font/woff2" crossorigin
71
- href="{{ pathto('_static/vendor/fontawesome/${
72
- vendorVersions . fontAwesome
73
- } /webfonts/fa-solid-900.woff2', 1) }}">
74
- <link rel="preload" as="font" type="font/woff2" crossorigin
75
- href="{{ pathto('_static/vendor/fontawesome/${
76
- vendorVersions . fontAwesome
77
- } /webfonts/fa-brands-400.woff2', 1) }}">
78
- <link rel="preload" as="font" type="font/woff2" crossorigin
79
- href="{{ pathto('_static/vendor/fontawesome/${
80
- vendorVersions . fontAwesome
81
- } /webfonts/fa-regular-400.woff2', 1) }}">
87
+ ${ font_files . map ( stylesheet ) . join ( "\n" ) }
88
+ ${ icon_files . map ( font ) . join ( "\n" ) }
82
89
{% endmacro %}
83
90
84
91
{% macro head_pre_assets() %}
@@ -102,9 +109,8 @@ module.exports = {
102
109
mode : "production" ,
103
110
devtool : "source-map" ,
104
111
entry : {
105
- "pydata-sphinx-theme" : [
106
- "./src/pydata_sphinx_theme/assets/scripts/index.js" ,
107
- ] ,
112
+ "pydata-sphinx-theme" : resolve ( scriptPath , "pydata-sphinx-theme.js" ) ,
113
+ bootstrap : resolve ( scriptPath , "bootstrap.js" ) ,
108
114
} ,
109
115
output : {
110
116
filename : "scripts/[name].js" ,
@@ -126,7 +132,7 @@ module.exports = {
126
132
{
127
133
loader : "file-loader" ,
128
134
options : {
129
- name : "styles/pydata-sphinx-theme .css" ,
135
+ name : "styles/[name] .css" ,
130
136
} ,
131
137
} ,
132
138
{
0 commit comments