P
P
prolina2019-07-06 15:39:33
React
prolina, 2019-07-06 15:39:33

Set up build scripts for create react app?

There is a website written with create-react-app.
The project structure is as follows:
5d209661d0d99867892249.png
5d20966d477b1405303623.png
That is, there are two package.json files.
Build of the project must be done from the REACT FLT.BY folder (it is also the root folder).
Package.json in this folder is the following:

{
        "name": "FLT",
        "version": "1.0.0",
        "description": "",
        "main": "server.js",
        "scripts": {
          "start": "node server.js",
          "server": "nodemon server.js",
          "client": "cd client && npm run start",
          "dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
          "build": "react-scripts build",
          "main_sectionku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build"
        },
        "keywords": [],
        "author": "",
        "license": "ISC",
        "dependencies": {
          "aos": "^2.3.4",
          "body-parser": "^1.19.0",
          "concurrently": "^4.1.0",
          "express": "^4.17.1",
          "nodemailer": "^6.2.1",
          "nodemon": "^1.19.1",
          "react-addons-css-transition-group": "^15.6.2",
          "react-loading-skeleton": "^1.1.2",
          "react-skroll": "^0.7.2",
          "react-transition-group": "^4.1.0"
        }
      }

You need to add build to scripts. But what should be written there? At the moment, it turns out to make a project build only if you go to the client folder. But some necessary logic is contained in the server.js file

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Spirin, 2019-07-07
@prolina

You, in a good way:
1. Combine dependencies and scripts from both package.json in what is located in the client folder, and delete the root.
2. Move the contents of the client folder to the root.

R
Robur, 2019-07-08
@Robur

in root package.json:
"build": "cd client; yarn build; cd .."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question