question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support absolute imports with `@`

See original GitHub issue

webpack.base.conf.js wrote as below:

resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      '@': resolve('src'),
    }
 },

https://github.com/vuejs-templates/webpack/blob/master/template/build/webpack.base.conf.js#L40

Can we use import Hello from '@/components/Hello' like vue?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:46
  • Comments:44 (18 by maintainers)

github_iconTop GitHub Comments

115reactions
gaearoncommented, Sep 27, 2018

I’d say let’s just add @ support. I was resistant because I thought we’d do monorepos sooner. But since that was shelved we might as well do what Vue does.

54reactions
gaearoncommented, Jan 3, 2019

There appears to be some confusion in other threads so I’ll repeat my comment from https://github.com/facebook/create-react-app/issues/5585:


Just to be clear — we do want to support absolute paths.

In particular, we want to:

I’m sorry for the frustration this is causing. We’re not asking you to convert your code to use relative paths — but please wait for either of these two issues to resolve.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Making Life Easier with Absolute Imports - React in Javascript ...
Absolute imports make the component more readable and clean. There are cases like very closely related components where relative imports makes ...
Read more >
Why and How to Use Absolute Imports in React
By using absolute imports, you can alias some folders to a name like below: import {MyComponent} from 'components/MyComponent';. Absolute ...
Read more >
Absolute Import in React | create-react-app - BezKoder
Absolute imports help to simplify the paths because the paths is now relative to the project root directory or custom base directory. With ......
Read more >
Absolute vs Relative Imports in Python
An absolute import specifies the resource to be imported using its full path from the project's root folder. Syntax and Practical Examples. Let's...
Read more >
Absolute imports in Create React App - DEV Community ‍ ‍
Absolute imports can help you make that code a lot cleaner, more readable and manageable. We want to be able to transform our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found