Skip to content

Inline PRERENDER=true env var during prerendering#625

Merged
lukeed merged 2 commits intomasterfrom
env-ssr
Aug 27, 2018
Merged

Inline PRERENDER=true env var during prerendering#625
lukeed merged 2 commits intomasterfrom
env-ssr

Conversation

@developit
Copy link
Copy Markdown
Member

Makes a PRERENDER env var defined that indicates whether the bundle was compiled for prerendering or client-side usage. This is useful for avoiding SSR-specific code ending up in client bundles.

Copy link
Copy Markdown
Member

@lukeed lukeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye, this is what I do -- probably grabbed it from you 😅

new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development')
'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development'),
'PRERENDER': env.ssr ? 'true' : 'false'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env.ssr.toString() 🏌️

}

export default function (env) {
env = Object.assign({}, env, { ssr: true });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.assign(env, { ssr:true }) ⛳️

@lukeed lukeed merged commit e621965 into master Aug 27, 2018
@ForsakenHarmony ForsakenHarmony deleted the env-ssr branch January 26, 2019 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants