electron-react-boilerplate / electron-react-boilerplate

A Foundation for Scalable Cross-Platform Apps

Home Page:https://electron-react-boilerplate.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I can not use javascript files by alias reference in the boilerplate project

yrito opened this issue · comments

commented

Summary

Hi,
I need call javascript file functionality reference javascript module as Alias inside the boilerplate project.
Ex: I create a ./src/renderer/utils/Util.js with one funcionality "test" that print e text in the terminal, very simple

  • I added alias in tsconfig.json:
compilerOptions": {
   ...
     "baseUrl": "./",
   "paths": {
     "@utils/*": ["./src/renderer/utils/*"]
   }
   }
  • And add alias in the webpack.config.base.ts:
resolve: {
      ...
      alias: {
           '@utils': path.resolve(__dirname, './src/renderer/utils/'), // Substitua pelo caminho correto para a pasta utils
      }, 
     ...
  }
  • After, call the class utils from App.tsx file as:
    _import Util from './utils/Util';_

  • and finality, whe start project, any time output:
    ERROR in ./src/renderer/utils/Util.js 3:0-33
    Module not found: Error: Can't resolve '@utils/Utils' in 'D:\WORKs\repos\Docker\erb-test\src\renderer\utils'

Can anybody help me?