简体   繁体   中英

Specifying project path with react-scripts

I have a react project inside of a folder and I want react-scripts to target and compile from a folder. It looks like this

project
│   README.md
│   package.json   
│
└───react
│   │   jsconfig.json
│   │
│   └───src
│   │
│   └───public
│   
└───api
    │   tsconfig.json
    │
    └───src

from the project/package.json I want to run react-scripts start and have it compile the /react folder. How can I do this?

I solved the issue with the use off react-app-rewired

See this stackoverflow post on details of how it was done.

const path = require('path');

module.exports = {
  paths: function (paths, env) {
    paths.appIndexJs = path.resolve(__dirname, 'react/src/index.js');
    paths.appSrc = path.resolve(__dirname, 'react/src');
    paths.appPublic = path.resolve(__dirname, 'react/public');
    paths.appHtml = path.resolve(__dirname, 'react/public/index.html');
    return paths;
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM