alienbuild
alienbuild

Reputation: 294

Create React App Blank Page when including on existing site

I'm using XAMPP locally to host an exisiting CMS and I want to include my react app within the CMS by using an include (this works fine for including static HTML and other PHP pages). The CMS admin page it'll be included on will look like this: http://localhost/website/administrator/

I need to place my create-react-app in a folder like this though so that the built in CMS script will include it: website\subfolder1\subfolder2\subfolder3\subfolder4\default

Currently I'm getting a blank page where I've tried to include my app. If I remove the embedded I can see the markup is being output, as in an empty div with the root class name.

I've tried setting a "homepage" property in my package.json and various combinations such as '.', and also edited the manifest site_start without luck, i can't seem to get it to render. Can anyone point me in the right direction?

Upvotes: 2

Views: 291

Answers (1)

Robert Anderson
Robert Anderson

Reputation: 1256

Here are some steps that you could try to get the bundles building correctly, as you will need to override the default behaviour of create-react-app by ejecting.

  1. Make a backup copy of your create-react-app
  2. Eject, so that you will now be able to configure webpack n

npm run eject

  1. Go to webpack config, see the scripts section

  2. You can change the build scripts as such as start and build

  3. The issue seems to be where the js and css files are built to. You can change where they are output in webpack by editing the config.

See link: https://webpack.js.org/configuration

You could try changing the path for the output section to where your cms html is trying to find the bundle.

Upvotes: 1

Related Questions