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.

resolve aliases in @import work during initial compile but error out during recompiles

See original GitHub issue

I have the following alias in my webpack config:

  resolve: {
    alias: {
      'mindfront-react-components': path.join(__dirname, '../mindfront-react-components'),
    }
  }

I have a sass file using this alias:

@import mindfront-react-components/css3-mixins

When I start up webpack-dev-server for the first time, the sass file compiles just fine. But if I make any changes to it, I get the following error when webpack-dev-server recompiles:

ERROR in ./~/css-loader!./~/sass-loader?indentedSyntax&outputStyle=expanded!./app/components/InventoryList.sass
Module build failed: 
@import mindfront-react-components/css3-mixins
       ^
      File to import not found or unreadable: mindfront-react-components/css3-mixins
      in /home/andy/jcore-portal/app/components/InventoryList.sass (line 1, column 9)
 @ ./app/components/InventoryList.sass 4:14-166 14:20-172

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
e110c0commented, Mar 2, 2017

it looks like a similar issue here with webpack 2:

alias: {
Styles:     path.resolve(__dirname, 'styles')
}

when I import in a sass file like this:

@import 'Styles/imports'; compile works, but the file imports is not watched.

@import '../../../styles/imports';

compile and watch works.

If found in webpack 1 configs that the import should use ~:

@import '~Styles/imports';

this also works for compile and watch. It looks like @import 'Styles/imports'; is not adding the files to the dependency tree for some reason.

0reactions
alexander-akaitcommented, May 3, 2017

Duplicate https://github.com/webpack-contrib/sass-loader/issues/410, If somebody don’t agree please create a separate issue. Thanks for helping sass-loader doing better 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack resolve alias and compile file under that alias
Problem occurs only for dependencies. Potential solutions. I know that one solution would be to compile each package with webpack - but that ......
Read more >
Module Resolution or Import Alias: The Final Guide - Raul Melo
Tired to have weird imports? It's time to learn how can you enable aliases to your imports and let code more organized.
Read more >
sass-loader - webpack - JS.ORG
The loader will first try to resolve @import as a relative path. If it cannot be resolved, then the loader will try to...
Read more >
how the Python import system works - Ten thousand meters
First, we'll discuss the core concepts of the import system: modules, submodules, packages, from <> import <> statements, relative imports, and ...
Read more >
SharePoint Framework development tips: prettify your imports
Readability of such code is not at the best level. A lot of parent relative paths like ... It's a common approach when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found