Skip to content

Commit a05e141

Browse files
committed
fix(theme): Conditionally load CSS to support dev and prod builds
The plugin's CSS was not loading in production builds. Adding it via getClientModules() fixed the build, but broke dark mode in development. This change makes the CSS loading conditional: - In production, getClientModules() is used to ensure the stylesheet is bundled. - In development, this is disabled, allowing Docusaurus's default handling to manage theme changes and hot-reloading correctly.
1 parent e0626ab commit a05e141

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,23 @@ export default function docusaurusPluginResistogram(
4040
);
4141
ensureDirSync(pluginDataDir);
4242

43+
const isProd = process.env.NODE_ENV === 'production';
44+
4345
return {
4446
name: "docusaurus-plugin-resistogram",
4547

4648
getThemePath() {
4749
return path.resolve(__dirname, "./theme");
4850
},
4951

52+
// Explicitly add the theme's stylesheet to the client modules only for the production build.
53+
// This is a workaround for an issue where the styles are not being picked up automatically
54+
// in the production build. In development, this is disabled to allow for hot-reloading
55+
// and correct dark mode behavior.
56+
getClientModules() {
57+
return isProd ? [path.resolve(__dirname, './theme/ResistanceTable/styles.module.css')] : [];
58+
},
59+
5060
async contentLoaded({ actions }: { actions: any }) {
5161
const { abx, org, sources, hierarchicalSources, allAbxIds, allOrgIds, orgClasses, orgIdToRank, abxSyn2Id, orgSyn2Id } = await getSharedData(dataPath, files);
5262

0 commit comments

Comments
 (0)