diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index ea8521a15..5b21525a6 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -201,7 +201,21 @@ export class Renderer extends ChildableComponent } } - this.theme = this.addComponent('theme', new DefaultTheme(this, path)); + const filename = Path.join(path, 'theme.js'); + if (!FS.existsSync(filename)) { + this.theme = this.addComponent('theme', new DefaultTheme(this, path)); + } else { + try { + const themeClass = typeof require(filename) === 'function' ? require(filename) : require(filename).default; + + this.theme = this.addComponent('theme', new (themeClass)(this, path)); + } catch (err) { + throw new Error( + `Exception while loading "${filename}". You must export a \`new Theme(renderer, basePath)\` compatible class.\n` + + err + ); + } + } } this.theme.resources.activate();