Skip to content

Commit

Permalink
improve stylesheet error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
suabahasa committed Feb 24, 2025
1 parent 67eca4d commit f1a88c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/apps/dashboard/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ channel.addEventListener('message', async (e) => {
notifier.success(`Cache generated in <b>${prettyMilliseconds(timeEnd - timeStart)}</b>`);
},
err => {
notifier.alert('Failed to generate cache');
notifier.alert(`Failed to generate cache. Check the Browser's Console for more information.`);
console.error('err', err);
},
'Generating cache...',
Expand Down
15 changes: 13 additions & 2 deletions assets/packages/core/tailwindcss-v4/stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export async function loadStylesheet(id, base, volume = {}) {
...twVolume
};

let _id = id;

if (isValidUrl(id)) {
return {
base: path.dirname(id),
Expand Down Expand Up @@ -79,8 +81,17 @@ export async function loadStylesheet(id, base, volume = {}) {

// fetch and store in volume
await fetch(`https://esm.sh/${_path}`)
.then((response) => response.text())
.then((data) => {
.then((response) => {
if (!response.ok) {
throw new Error(
_id.startsWith('.')
? `Cannot find stylesheet '${_id}' on the Simple File System`
: `Cannot find stylesheet '${_id}' on the CDN`
);
}

let data = response.text();

data = data
// resolve the `@config '|"` imports paths to absolute paths with cdn
.replace(/@config\s+['|"](.*)['|"]/g, (match, p1) => {
Expand Down

0 comments on commit f1a88c8

Please sign in to comment.