Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby): use production React for dev-ssr when CI=true #28728

Merged
merged 3 commits into from
Dec 29, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require(`v8-compile-cache`)

const { isCI } = require(`gatsby-core-utils`)
KyleAMathews marked this conversation as resolved.
Show resolved Hide resolved
const crypto = require(`crypto`)
const fs = require(`fs-extra`)
const path = require(`path`)
Expand Down Expand Up @@ -95,6 +96,10 @@ module.exports = async (
)
}

if (stage === `develop-html`) {
envObject.CI = JSON.stringify(process.env.CI || `false`)
}

const mergedEnvVars = Object.assign(envObject, gatsbyVarObject)

return Object.keys(mergedEnvVars).reduce(
Expand Down Expand Up @@ -675,6 +680,23 @@ module.exports = async (

config.externals = [
function (context, request, callback) {
if (
stage === `develop-html` &&
isCI() &&
KyleAMathews marked this conversation as resolved.
Show resolved Hide resolved
process.env.GATSBY_EXPERIMENTAL_DEV_SSR
) {
if (request === `react`) {
callback(null, `react/cjs/react.production.min.js`)
return
} else if (request === `react-dom/server`) {
callback(
null,
`react-dom/cjs/react-dom-server.node.production.min.js`
)
return
}
}

const external = isExternal(request)
if (external !== null) {
callback(null, external)
Expand Down