Skip to content

Commit 963dd13

Browse files
committed
fix: πŸ› Load Truss components from an external CDN
Truss components were breaking because of a Webpack configuration issue. While the exact issue isn't clear, there is a lot webpack in the modern WordPress front end. Rather than load Truss components using webpack, we'll load them externally from unpkg until a better solution emerges, if there is one.
1 parent d92962f commit 963dd13

File tree

7 files changed

+13
-117
lines changed

7 files changed

+13
-117
lines changed

β€Žfunctions.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ function ucsc_favicons() { ?>
6666
<link rel="apple-touch-icon" href="<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/images/favicons/apple-icon.png">
6767
<link rel="manifest" href="<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/images/favicons/manifest.webmanifest">
6868

69-
<!-- Script and style to include our components library, Truss. -->
70-
<script type="module" src="<?php echo esc_url( get_template_directory_uri() ); ?>/build/truss.js"></script>
71-
<link rel="stylesheet" href="<?php echo esc_url( get_template_directory_uri() ); ?>/build/truss.css">
72-
7369
<?php
7470
}
7571
add_action( 'wp_head', 'ucsc_favicons' );
@@ -349,3 +345,13 @@ function ucsc_add_custom_body_close_code() {
349345
}
350346

351347

348+
add_action( 'wp_footer', 'ucsc_truss_assets' );
349+
350+
function ucsc_truss_assets() { ?>
351+
352+
<!-- Script and style to include our components library, Truss. -->
353+
<script type="module" src="https://unpkg.com/@ucsantacruz/truss@latest/dist/ucsc-trss/ucsc-trss.esm.js"></script>
354+
<link rel="stylesheet" href="https://unpkg.com/@ucsantacruz/truss@latest/dist/ucsc-trss/ucsc-trss.css">
355+
356+
<?php
357+
}

β€Žpackage-lock.json

Lines changed: 0 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,5 @@
5959
"style.css",
6060
"patterns",
6161
"*.php"
62-
],
63-
"dependencies": {
64-
"@ucsantacruz/truss": "^0.7.5"
65-
}
62+
]
6663
}

β€Žsrc/scss/style.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@
2727
//===============================
2828
@import "theme-regions/footer";
2929
@import "theme-regions/site-header";
30-
@import "theme-regions/ucsc-footer";
3130
@import "theme-regions/site-footer";

β€Žsrc/scss/theme-regions/_ucsc-footer.scss

Lines changed: 0 additions & 52 deletions
This file was deleted.

β€Žsrc/truss.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

β€Žwebpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
* External Dependencies
33
*/
44
const path = require('path');
5-
const CopyPlugin = require('copy-webpack-plugin');
65
/**
76
* WordPress Dependencies
87
*/
98
const defaultConfig = require('@wordpress/scripts/config/webpack.config.js');
109

10+
console.log();
11+
1112
module.exports = {
1213
...defaultConfig,
1314
...{
1415
entry: {
1516
index: path.resolve(process.cwd(), 'src', 'index.js'),
1617
theme: path.resolve(process.cwd(), 'src', 'theme.js'),
17-
truss: path.resolve(process.cwd(), 'src', 'truss.js'),
1818
},
1919
},
2020
};

0 commit comments

Comments
Β (0)