Skip to content

Commit

Permalink
also load themes from node_modules/${theme_name}
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeh committed Feb 6, 2020
1 parent 055a5f2 commit 58c1d43
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/tasks/prepare/css.mjs
Expand Up @@ -72,7 +72,21 @@ export const prepareCss = async ({ app, modules }) => {
}
}

// look if it exists in node_modules
// look if it exists in node_modules/${theme_name}
try {
let { default: theme } = await import(theme_name)
if (is.function(theme)) {
theme = theme(THEME_VARS)
}
styles.push(theme)
} catch (e) {
if (!e.code || !e.code.includes('MODULE_NOT_FOUND')) {
throw error(e)
}
// theme does not exist in node_modules, continue happily.
}

// look if it exists in node_modules/@magic-themes/${theme_name}
try {
const themePath = `@magic-themes/${theme_name}`
let { default: theme } = await import(themePath)
Expand Down

0 comments on commit 58c1d43

Please sign in to comment.