sass-loader in webpack ignoring tsconfig paths

It appears that the Sass-loader is not utilizing the path alias declared in the typescript configuration. When using @use or @import, it results in a "not found" error.

Webpack

resolve: {
    plugins: [new TsconfigPathsPlugin()],

tsconfig

"paths": {
    "Components/*": ["src/components/*"],

The issue

SassError: Can't find stylesheet to import.
1 │ @use 'Components/UI/Grid';

Is there any way to incorporate the tsconfig path into the sass-loader?

Answer №1

The reason for this issue is that the extensions option in TsconfigPathsPlugin does not include '.scss', causing imported files to be missing their extension.

Resolution 1:

Specify the full file name like so

@use 'Components/UI/Grid.scss';

Resolution 2:

Add the extension .scss to TsconfigPathsWebpackPlugin

plugins: [
  new TsconfigPathsWebpackPlugin({
    extensions: ['.js', '.ts', '.vue', '.json', '.scss'],
  }),
],

Consider adding a console.log statement in the

node_modules/tsconfig-paths/lib/try-path.js
under the getPathsToTry function for debugging assistance.

function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
    // Function logic here
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular 9 - Button unable to be clicked under certain conditions

I have a webpage that contains a lot of information, and I would like to make it easier for the user to show/hide specific parts by clicking on buttons. Check out this stackblitz to see what I've done. Here's a brief summary of the code: <but ...

Troubleshooting data binding problems when using an Array of Objects in MatTableDataSource within Angular

I am encountering an issue when trying to bind an array of objects data to a MatTableDataSource; the table displays empty results. I suspect there is a minor problem with data binding in my code snippet below. endPointsDataSource; endPointsLength; endP ...

Data string not being converted correctly to date format

Here is a table I am currently working with: ID DateColumn 1 3/7/2019 5:29:38 AM 2 3/8/2019 5:28:38 AM 3 3/7/2019 5:30:38 AM 4 3/7/2019 5:31:38 AM The date column in this table is being processed as a string when bound to the grid. To ...

Storing checkbox status in Angular 7 with local storage

I am looking for a way to keep checkboxes checked even after the page is refreshed. My current approach involves storing the checked values in local storage, but I am unsure of how to maintain the checkbox status in angular 7 .html <div *ngFor="let i ...

Maintaining accurate type-hinting with Typescript's external modules

Before I ask my question, I want to mention that I am utilizing Intellij IDEA. In reference to this inquiry: How do you prevent naming conflicts when external typescript modules do not have a module name? Imagine I have two Rectangle classes in different ...

Angular2: PrimeNG - Error Retrieving Data (404 Not Found)

I'm facing an issue with using Dialog from the PrimeNG Module. The error message I keep getting is: Unhandled Promise rejection: (SystemJS) Error: XHR error (404 Not Found) loading http://localhost:4200/node_modules/primeng/primeng.js I followed the ...

Using Typescript with Vue.js: Defining string array type for @Prop

How can I properly set the type attribute of the @Prop decorator to be Array<string>? Is it feasible? I can only seem to set it as Array without including string as shown below: <script lang="ts"> import { Component, Prop, Vue } from ...

Typescript - The Power of Dynamic Typing

Currently, I am attempting to demonstrate this example => typescript playground const obj = { func1: ({ a }: { a: string }) => { console.log(a) }, func2: ({ b }: { b: number }) => { console.log(b) }, } function execFunction<Key extends ...

ReactJS and Redux: setting input value using properties

I am utilizing a controlled text field to monitor value changes and enforce case sensitivity for the input. In order to achieve this, I need to access the value property of the component's state. The challenge arises when I try to update this field ...

Tips on how child component can detect when the object passed from parent component has been updated in Angular

In the child component, I am receiving an object from the parent component that looks like this: { attribute: 'aaaa', attribute2: [ { value }, { value }, { value }, ] } This object is passed to th ...

The Angular filter feature operates on individual columns instead of filtering all columns simultaneously

Introduction I am currently working on implementing a feature in my Angular application where the column filter continuously updates the results based on the selected filters. The issue I'm facing is that when I select a filter in one column, it corr ...

A guide to confirm if an object includes an HTML element without compromising safety

When I implement a function that is triggered by a click event: useEffect(() => { document.addEventListener('click', (e) => handleClickOutside(e), true); }); The function itself: const myElement = useRef(null); const handleCli ...

Need help in NestJS with returning a buffer to a streamable file? I encountered an error stating that a string is not assignable to a buffer parameter. Can anyone provide guidance on resolving this issue?

The issue description: I am having trouble returning a StreamableFile from a buffer. I have attempted to use buffer.from, but it does not seem to work, resulting in the error message below. Concern in French language: Aucune surcharge ne correspond à cet ...

Running TypeScript Jest tests in Eclipse 2020-12: A step-by-step guide

Having a TypeScript project with a test suite that runs smoothly using npm test in the project directory from the console. Is there a feature within Eclipse that can facilitate running these tests directly within the IDE, similar to how Java tests are ex ...

Determine characteristics of object given to class constructor (typescript)

My current scenario involves the following code: abstract class A { obj; constructor(obj:{[index:string]:number}) { this.obj = obj; } } class B extends A { constructor() { super({i:0}) } method() { //I wan ...

Code not running properly after activating webpack watch

My AngularJS (1.6) app is built using webpack 3.10. The entry file, Application.ts, sets up the module, runs it, and then boots it to the document. Initially, everything works perfectly after the first build. However, when I make a change, let webpack wat ...

Restricting Method Arguments in TypeScript to a Specific Type

I am looking to restrict the calling party from inputting arbitrary strings as parameters to a method: // A class that provides string values (urls) class BackendUrls { static USERS_ID = (id: string) => `/users/${id}`; static CONSTANTS ...

Unauthorized error encountered when making an Ajax GET request to Azure Ad Graph API

I've been attempting to make calls to the Azure Ad Graph API from my typescript code, but I keep encountering the "Unauthorized" error. lavaNET.SharePointREST.getJsonWithoutSite(this, "https://graph.windows.net/lavanet.dk/users?api-version=1.6", (tmp ...

Convert a TypeScript array of strings to a boolean array: a step-by-step guide

Upon receiving a list of objects from the front end as: item=["false","true"] I proceed to check a column within my records to identify values containing "true" or "false" using the following code: this.records.filter(x=> items.includes(x.column)) Unf ...

Sharing references in React Native using TypeScript: The (property) React.MutableRefObject<null>.current is potentially null

I'm working on a React Native form with multiple fields, and I want the focus to move from one field to the next when the user validates the input using the virtual keyboard. This is what I have so far: <NamedTextInput name={&apo ...