title: Webpack, sass-loader (or css-loader) nested file imports inside node_modules. File not found
body: <p>I want to use primercss framework as sass. I am using webpack to build my application. I have downloaded the npm package and imported it using: @import <code>"~primer-css/index.scss";</code>. The problem is that the build fails with this error: <code>File to import not found or unreadable: primer-core/index.scss</code> , which is a subimport in the <code>primer-css/index.scss</code> file. I think that it is a problem related to the webpack sass-loader or css-loader, the full-stack trace is the following: </p>
  
  <pre><code>ERROR in ./node_modules/css-loader?{"modules":true,"minimize":true,"sourceMap":true,"importLoaders":2,"localIdentName":"[name]__[local]"}!./node_modules/postcss-loader/lib?{"config":{"path":"/Users/vicaba/Projects/medself/medself-client/development/webpack/postcss.config.js"},"sourceMap":true}!./node_modules/sass-loader/lib/loader.js?{"outputStyle":"expanded","sourceMap":true,"sourceMapContents":true}!./src/theme/theme.scss
  Module build failed:
  @import "primer-core/index.scss";
  ^
        File to import not found or unreadable: primer-core/index.scss.
  Parent style sheet: /Users/vicaba/Projects/medself/medself-client/development/node_modules/primer-css/index.scss
        in /Users/vicaba/Projects/medself/medself-client/development/node_modules/primer-css/index.scss (line 14, column 1)
  Error:
  @import "primer-core/index.scss";
  ^
        File to import not found or unreadable: primer-core/index.scss.
  Parent style sheet: /Users/vicaba/Projects/medself/medself-client/development/node_modules/primer-css/index.scss
        in /Users/vicaba/Projects/medself/medself-client/development/node_modules/primer-css/index.scss (line 14, column 1)
      at options.error (/Users/vicaba/Projects/medself/medself-client/development/node_modules/node-sass/lib/index.js:291:26)
   @ ./src/theme/theme.scss 4:14-200
   @ ./src/bootstrap.js
   @ multi ./src/bootstrap.js
  
  ERROR in ./src/theme/theme.scss
  Module build failed: ModuleBuildError: Module build failed:
  @import "primer-core/index.scss";
  ^
        File to import not found or unreadable: primer-core/index.scss.
  Parent style sheet: /Users/vicaba/Projects/medself/medself-client/development/node_modules/primer-css/index.scss
        in /Users/vicaba/Projects/medself/medself-client/development/node_modules/primer-css/index.scss (line 14, column 1)
      at runLoaders (/Users/vicaba/Projects/medself/medself-client/development/node_modules/webpack/lib/NormalModule.js:194:19)
      at /Users/vicaba/Projects/medself/medself-client/development/node_modules/loader-runner/lib/LoaderRunner.js:364:11
      at /Users/vicaba/Projects/medself/medself-client/development/node_modules/loader-runner/lib/LoaderRunner.js:230:18
      at context.callback (/Users/vicaba/Projects/medself/medself-client/development/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
      at Object.asyncSassJobQueue.push [as callback] (/Users/vicaba/Projects/medself/medself-client/development/node_modules/sass-loader/lib/loader.js:55:13)
      at Object.&lt;anonymous&gt; (/Users/vicaba/Projects/medself/medself-client/development/node_modules/async/dist/async.js:2244:31)
      at Object.callback (/Users/vicaba/Projects/medself/medself-client/development/node_modules/async/dist/async.js:906:16)
      at options.error (/Users/vicaba/Projects/medself/medself-client/development/node_modules/node-sass/lib/index.js:294:32)
  </code></pre>
  
  <p>The loaders configuration is the following:</p>
  
  <pre><code>{
    test: /\.scss$/,
    use: ExtractTextPlugin.extract({
      fallback: 'style-loader',
      use: [
        {
          loader: 'css-loader',
          options: {
            modules: true,
            minimize: true,
            sourceMap: true,
            importLoaders: 2,
            localIdentName: '[name]__[local]'
          }
        },
        {
          loader: 'postcss-loader',
          options: {
            config: {
              path: path.resolve(__dirname, 'postcss.config.js')
            },
            sourceMap: true
          }
        },
        {
          loader: 'sass-loader',
          options: {
            outputStyle: 'expanded',
            sourceMap: true,
            sourceMapContents: true
          }
        }
      ]
    })
  }
  </code></pre>
  
  <p>Can anyone help me? Or shed some light on the problem?</p>