Parcel: @ on import for root path

Created on 12 Mar 2019  路  2Comments  路  Source: parcel-bundler/parcel

In webpack using @ for root src folder:

import Home from '@/components/Home';

When try use '@', Parcel try install "@/..." package with npm. I use Windows.
I want some similar in parcel for avoid things such as "../../../" or similar, depends component path. Options?

Recommends?

Question

Most helpful comment

@DeMoorJasper correct!

Fast summary, for users for this issue:

| Import path method | Comments | Parcel support |
|------------------------|-------------|-----------------|
| import Component from '@/components/Home' | non standard | no |
| import Component from '~/components/Home' | | yes, maybe removed in Parcel 2 |
| import Component from '/components/Home' | | yes |

Thanks!

All 2 comments

Parcel supports / and ~/ they are documented in the docs. They have pretty similar results. (I think ~/ will be removed in parcel 2 though)

we dont and will not support @/ afaik because parcel 1 has been feature locked and because it鈥檚 non standardised. You鈥檒l be able to write your own resolver for parcel 2 if there is a need for @/

Try / and see if it works

Sent with GitHawk

@DeMoorJasper correct!

Fast summary, for users for this issue:

| Import path method | Comments | Parcel support |
|------------------------|-------------|-----------------|
| import Component from '@/components/Home' | non standard | no |
| import Component from '~/components/Home' | | yes, maybe removed in Parcel 2 |
| import Component from '/components/Home' | | yes |

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oliger picture oliger  路  3Comments

Niggler picture Niggler  路  3Comments

mnn picture mnn  路  3Comments

devongovett picture devongovett  路  3Comments

philipodev picture philipodev  路  3Comments