coreui / coreui-free-react-admin-template

Open source admin template based on Bootstrap 5 and React.js
https://coreui.io/product/free-react-admin-template/
MIT License
4.6k stars 2.33k forks source link

Path alias in jsconfig isnt working #381

Closed q8tywolf closed 2 years ago

q8tywolf commented 2 years ago

I am including the path alias in the jsconfig.json like below

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "assets": [
        "./src/assets/*"
      ],
      "components": [
        "./src/components/*"
      ],
      "layout": [
        "./src/layout/*"
      ],
      "scss": [
        "./src/scss/*"
      ],
      "views": [
        "./src/views/*"
      ]
    }
  },
  "include": [
    "src"
  ]
}

when I use the alias like below, I get an error

Failed to compile.

Module not found: Error: Can't resolve 'components/index' in '/home/dev/coreui-free-react-admin-template/src/layout'
ERROR in ./src/layout/DefaultLayout.js 5:0-80
Module not found: Error: Can't resolve 'components/index' in '/home/dev/coreui-free-react-admin-template/src/layout'
import React from 'react'
import { AppContent, AppSidebar, AppFooter, AppHeader } from 'components/index'

const DefaultLayout = () => {
  return (
    <div>
      <AppSidebar />
      <div className="wrapper d-flex flex-column min-vh-100 bg-light">
        <AppHeader />
        <div className="body flex-grow-1 px-3">
          <AppContent />
        </div>
        <AppFooter />
      </div>
    </div>
  )
}

export default DefaultLayout
github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions