DEV Community

Discussion on: Setup a React.JS Project with TypeScript, ESLint and Prettier without create-react-app

Collapse
 
erikgmatos profile image
Erik Garces Matos • Edited

Bom dia Renato, ótimo post parabéns, só não consegui fazer funcionar o plugin babel-plugin-root-import, sabe se ele funciona com typescript? eu fiz as configs no arquivo babelrc e eslintrc e ele acha as pastas porem quandodo coloco o nome da imagem(image.svg ou image.png) ele fica dando erro...
module "*.png"
Unable to resolve path to module '~/assets/png/1.icone.png'

se eu coloco o caminho relativo comum('../assets/png/1.icone.png') funciona....sabe o q pode ser?

Collapse
 
renatobentorocha profile image
Renato Rocha

Hi Erik, tanks by comments!

To that with React.JS we need use: customize-cra and react-app-rewired. I already did it, but I not wrote a post about it. So I found this article that could help you whit it.

This is my repo with this config.

In TypeScript I believe we config the tsconfig.json with:

   "baseUrl": "./src",
    "paths": {
      "~/*": ["*"] // resolve any `~/foo/bar` to `<baseUrl>/foo/bar`
    }

Obs: My repo and the article not use TypeScript.

Best regard