From ce8a9ff6911351365b7706a2fbf058751676d679 Mon Sep 17 00:00:00 2001 From: Victor Lin Date: Fri, 22 Feb 2019 13:20:03 -0800 Subject: [PATCH 1/3] add static build flag --- src/withStyles.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/withStyles.jsx b/src/withStyles.jsx index 79ad8650..ec327e38 100644 --- a/src/withStyles.jsx +++ b/src/withStyles.jsx @@ -136,6 +136,10 @@ export function withStyles( || WrappedComponent.name || 'Component'; + if (typeof window === 'undefined' && global.WITH_STYLES_STATIC_BUILD) { + getStyleDef(defaultDirection, wrappedComponentName); + } + // NOTE: Use a class here so components are ref-able if need be: // eslint-disable-next-line react/prefer-stateless-function class WithStyles extends BaseClass { From 11950c2d8abdfc978bed4d277f8cd8a8b0341e90 Mon Sep 17 00:00:00 2001 From: Victor Lin Date: Fri, 22 Feb 2019 13:26:06 -0800 Subject: [PATCH 2/3] use an env var --- src/withStyles.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/withStyles.jsx b/src/withStyles.jsx index ec327e38..07c888ab 100644 --- a/src/withStyles.jsx +++ b/src/withStyles.jsx @@ -136,7 +136,7 @@ export function withStyles( || WrappedComponent.name || 'Component'; - if (typeof window === 'undefined' && global.WITH_STYLES_STATIC_BUILD) { + if (typeof window === 'undefined' && process.env.WITH_STYLES_STATIC_BUILD) { getStyleDef(defaultDirection, wrappedComponentName); } From be44f986197eeda84a9d238fe9bd5c033bf7a51d Mon Sep 17 00:00:00 2001 From: Victor Lin Date: Mon, 25 Feb 2019 11:35:52 -0800 Subject: [PATCH 3/3] Update withStyles.jsx --- src/withStyles.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/withStyles.jsx b/src/withStyles.jsx index 07c888ab..d3748483 100644 --- a/src/withStyles.jsx +++ b/src/withStyles.jsx @@ -136,7 +136,9 @@ export function withStyles( || WrappedComponent.name || 'Component'; - if (typeof window === 'undefined' && process.env.WITH_STYLES_STATIC_BUILD) { + if (process.env.WITH_STYLES_STATIC_BUILD) { + // Usually we wait for the component to be rendered to generate styles. + // This flag forces immediate generation. getStyleDef(defaultDirection, wrappedComponentName); }