Closed zane-programs closed 3 years ago
The paths are set up in https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/paths.js
It looks like the react-app-env.d.ts path is under the variable name appTypeDeclarations
, so you should be able to get this working by setting that variable in the paths config as well:
const path = require("path");
module.exports = {
paths: function(paths, env) {
paths.appIndexJs = path.resolve(__dirname, "client/index.tsx");
paths.appSrc = path.resolve(__dirname, "client");
paths.appTypeDeclarations = path.resolve(__dirname, "client/react-app-env.d.ts");
return paths;
},
};
Looking at the react-scripts paths.js file, three other variables that you should probably also be setting as they directly reference the src
directory are testsSetup
, proxySetup
and swSrc
. :)
Ah, phew. Totally my bad on this one—I should have taken a closer look there. Thank you very much!
I am currently working on a project with a repository that will house both my backend (Node.js) and frontend (React + TypeScript) codebases. To be clear, this is something I'll be running on a Raspberry Pi in my home, so for this project I was planning to put both in one repository, with my React code living in a folder called
client
and my Node.js code living inserver
.Because it's not natively possible to rename the
src
folder toclient
withcreate-react-app
, I decided to usereact-app-rewired
to change that. First, I changed the compilation folder intsconfig.json
toclient
. Next, I put the following configuration inconfig-overrides.js
:This appears to work until I run
sudo npm start
, at which point I am presented with this nasty output:Oh, no!
react-scripts
is still looking for the filereact-app-env.d.ts
in the nonexistentsrc
folder. I found that a temporary solution for this problem solution was to create an empty folder calledsrc
in the root directory and copyreact-app-env.d.ts
fromclient
. Unfortunately, in terms of repository organization, this could become quite confusing.Is there a way to direct
react-scripts
to look in my newappSrc
path for thereact-app-env.d.ts
file, or is this uncharted territory?