Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for Webpack resolve.alias #5287

Closed
andrii-oleksyshyn opened this issue Mar 7, 2017 · 6 comments
Closed

No support for Webpack resolve.alias #5287

andrii-oleksyshyn opened this issue Mar 7, 2017 · 6 comments

Comments

@andrii-oleksyshyn
Copy link

Hello,

It's a copy of issue #5031, it was closed as already implemented but I couldn't manage to make it work.

Steps to reproduce:

I've added this to my tsconfig.json:

"compilerOptions": {
  "baseUrl": "src",
  "paths": {
      "shared/*": ["app/shared/*"]
  }
}

Path to the constants file: src/app/shared/constants/index.ts

When I import it as usual import { testConst } from './shared/constants/index';, it works fine:

But when I use absolute path, it crashes:
import { testConst } from 'shared/constants/index';

Webpack error:

ERROR in C:/Projects/myProject/UI/src/app/app.component.ts (2,27): Cannot find module 'shared/constants/index'.)
ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'shared/constants/index' in 'C:\Projects\myProject\UI\src\app'

Could someone confirm that this feature works? Does it need additional config?

@antonberezan
Copy link

Seems it has nothing to do with #5031. The issue definitely with WebPack config. I've looked through the sources, cli doesn't add resolve.alias in Webpack config. See here, it adds node_modules path only.
So, I decided to add my alias manually in that file and it worked.

Seems we need to expand angular-cli config for aliases. WDYT guys?

@andrii-oleksyshyn
Copy link
Author

There was already discussion(#1465) regarding expending of angular-cli config and implementing this feature.

@filipesilva
Copy link
Contributor

Dupe of #5031, I will followup to your question there.

@thomaswmanion
Copy link

Could we reopen this for support for Sass? There doesn't seem to currently be a way to alias CSS...

@prakashk-dev
Copy link

prakashk-dev commented Jan 8, 2018

As @thomaswmanion said, the alias for sass is not working. This is how my path looks like now when I try to import the global style.scss file @import '../../.././styles.scss'. Looks Weird and the alias does not work for that :(

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants