Skip to content

3.2.2 breaks resolve-url loader #254

@Hufschmidt

Description

@Hufschmidt

Issue

It seems like either commit e0ce2b4 breaks resolve-url loader, or there is something wrong with my webpack config (working flawlessly with 3.2.1).

Upon switching to sass-loader 3.2.2 from 3.2.1 (tested working) I get the following warning during bundling:

 WARNING in ../~/css-loader?sourceMap!../~/resolve-url-loader?sourceMap!../~/sass-loader?sourceMap!./scss/ionic.scss

  resolve-url-loader cannot operate: source-map error
  cannot establish a common base path for all sources in the incoming source-map

Additionally, relative url(...) paths (eg. fonts used by ionicons) produce error because they can not be resolved anymore:

 ERROR in ../~/css-loader?sourceMap!../~/resolve-url-loader?sourceMap!../~/sass-loader?sourceMap!./scss/ionic.scss

 Module not found: Error: Cannot resolve 'file' or 'directory' ../fonts/noto-sans-bold.ttf in /some/absolute/path/to/project/src/scss
  @ ../~/css-loader?sourceMap!../~/resolve-url-loader?sourceMap!../~/sass-loader?sourceMap!./scss/ionic.scss 6:393227-393265 6:393456-393494

The later is obviously emited because resolve-url has problems with the source-maps generated with sass-loaders current settings.

Webpack-Config

{
  context:                helpers.root('src'),
  entry: {
    'app':                './app.ts'
  },
  output: {
    filename:             '[name].bundle.js',
    sourceMapFilename:    '[name].bundle.map',
    chunkFilename:        '[id].chunk.js'
    path:                 helpers.root('www')
  },
  resolve: {
    extensions:           [ '', '.ts', '.js', '.scss' ],
    root:                 helpers.root(),
    modulesDirectories:   ['node_modules']
  },
  module: {
    loaders: [
      {
        test:             /\.ts$/,
        loader:           'awesome-typescript-loader',
        include:          [ helpers.root('src') ]
      },
      {
        test:           /\.scss$/,
        loader:         'style-loader!css-loader?sourceMap!resolve-url?sourceMap!sass-loader?sourceMap',
        include:        [ helpers.root('src/scss'), helpers.root('node_modules') ]
      },
      {
        test:                 /\.(svg|woff|woff2|eot|ttf)(\?.*$|$)/,
        loader:               'file-loader',
        include:          [ helpers.root('src'), helpers.root('node_modules') ]
      }
    ]
  },
  sassLoader: {
    includePaths: [
      'node_modules/ionicons/dist/scss/'
    ]
  },
  plugins: [
    new PluginHTML({
      template:             './app.html',
      inject:               'body',
      chunksSortMode:       'dependency'
    })
  ],
  devtool:              'cheap-module-eval-source-map',
  debug:                true
};

Full config

Details

In my main entry-point app.ts I do a require('./scss/ionic.scss');. Inside I fine-tune some scss variables and then @import '~ionic-angular/ionic.scss' code. The same error happens btw. when directly including ionic-angular/ionic.scss via require('ionic-angular/ionic.scss') instead.

The transpiled css code will then be inserted into a style-tag globally by the final style-loader, where it is available to be used by ionic components and directives.

Of course I could always fix this issue by setting $font-path: '../../node_modules/ionic-angular/fonts' inside my ./scss/ionic.scss file, but up until 3.2.2 the resolve-url loader was able to resolve relative url(...) paths for me, which I feel was a great boon. :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions