Closed
Description
My solution:
yarn add react-app-rewired --dev
Update
package.json
scripts:"scripts": { "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test --env=jsdom", "eject": "react-app-rewired eject" },Add
config-overrides.js
to project root:const path = require('path'); module.exports = function override(config) { config.resolve = { ...config.resolve, alias: { '@': path.resolve(__dirname, 'src') }, }; return config; };Add
jsconfig.paths.json
/tsconfig.paths.json
to project root:{ "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["src/*"] } } }Add the following to
jsconfig.json
/tsconfig.json
:"extends": "./tsconfig.paths.json", // or jsconfig.paths.jsonCRA warns about
compilerOptions.baseUrl
andcompilerOptions.paths
not being supported but everything works as expected.
Thanks for your solution. One silly question, how I can use to solution to avoid using '@'? I mean, instead of doing `@/components/DummyComponent' I would like to do 'components/DummyComponent'.
Originally posted by @jjvainstein in #5118 (comment)
Metadata
Metadata
Assignees
Labels
No labels