Skip to content

Extract loader doesn't work with css-loader 5.x #99

@edariedl

Description

@edariedl

Issue was originally raised in css loader from someone else webpack-contrib/css-loader#1215. It was closed as a problem in extract-loader. I have encountered the same problem today.

css loader changed the way css with sourcemaps are handled and they have added this method https://github.com/webpack-contrib/css-loader/blob/master/src/runtime/cssWithMappingToString.js

When we importe css file from some node module for (me it was tippy.js via @import 'tippy.js/dist/tippy.css';), following errors is raised

ERROR in ./assets/stylesheets/web.scss
Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
TypeError: Cannot read property 'sources' of undefined
    at cssWithMappingToString (/node_modules/css-loader/dist/runtime/cssWithMappingToString.js:25:33)
    at /node_modules/css-loader/dist/runtime/api.js:14:21
    at Array.map (<anonymous>)
    at Array.toString (/node_modules/css-loader/dist/runtime/api.js:13:17)
    at extractExports (/node_modules/extract-loader/lib/extractLoader.js:182:269)
    at /node_modules/extract-loader/lib/extractLoader.js:171:45
    at Generator.next (<anonymous>)
    at step (/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

I tried to dig a bit deeper and it looks like css-loader gets this array to process from extract-loader

[
  null,
  '__EXTRACT_LOADER_PLACEHOLDER__92066672257124958810185066705107',
  ''
]

which causes an error in the method mentioned above.

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