From 3c0f5ff852edcee5baddd9accd13f1e5c42418e0 Mon Sep 17 00:00:00 2001 From: Illia Kovalenko <23364749+illiakovalenko@users.noreply.github.com> Date: Wed, 31 Aug 2022 13:49:53 +0300 Subject: [PATCH] [React] App fails to open in Experience Editor/Headless ssr proxy (#1136) * [React] App fails to open in Experience Editor/Headless ssr proxy * Add `isDev` to helpers --- .../src/common/processes/transform.ts | 2 ++ .../react/server/server.webpack.config.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/create-sitecore-jss/src/common/processes/transform.ts b/packages/create-sitecore-jss/src/common/processes/transform.ts index 65eb1ec7eb..bf34c3ff2a 100644 --- a/packages/create-sitecore-jss/src/common/processes/transform.ts +++ b/packages/create-sitecore-jss/src/common/processes/transform.ts @@ -11,6 +11,7 @@ import { openPackageJson, sortKeys, writeFileToPath, + isDevEnvironment, } from '../utils/helpers'; import { diffLines, diffJson, Change } from 'diff'; import { BaseArgs } from '../args/base'; @@ -209,6 +210,7 @@ export const transform = async ( const ejsData: Data = { ...answers, helper: { + isDev: isDevEnvironment(answers.destination), getPascalCaseName: getPascalCaseName, getAppPrefix: getAppPrefix, }, diff --git a/packages/create-sitecore-jss/src/templates/react/server/server.webpack.config.js b/packages/create-sitecore-jss/src/templates/react/server/server.webpack.config.js index fc97dacd92..60e6acace7 100644 --- a/packages/create-sitecore-jss/src/templates/react/server/server.webpack.config.js +++ b/packages/create-sitecore-jss/src/templates/react/server/server.webpack.config.js @@ -37,6 +37,13 @@ module.exports = { options: { babelrc: false, presets: [env, reactApp], + plugins: [ + [ + '@babel/plugin-proposal-private-methods', + { loose: true } + ], + ["@babel/plugin-proposal-private-property-in-object", { "loose": true }] + ] }, }, }, @@ -72,4 +79,12 @@ module.exports = { // > Critical dependency: the request of a dependency is an expression new webpack.NormalModuleReplacementPlugin(/\/iconv-loader$/, () => {}), ], + <% if (helper.isDev) { %> + resolve: { + symlinks: false, + alias: { + react: path.resolve(process.cwd(), '.', 'node_modules', 'react') + } + }, + <% } %> };