Skip to content

sourceMap always prepend a undefined #1034

Closed
@DavidKk

Description

@DavidKk

I found that sourceRoot does not necessarily exist, sometimes it equals undefined.

I look for some codes, and found that extract-loader, it uses extractExports function to transform, (Function toString()) sandbox.module.exports.

And the css-loader use cssWithMappingToString and the variables cssMapping.sourceRoot to concat string, but css-loader has been remove the sourceRoot before cssWithMappingToString, so that cssWithMappingToString can not found sourceRoot anymore, and sourceRoot always to undefined

I suggest css-loader can compatibles it, when the sourceRoot is undefined, or keeps the sourceRoot option.

Environment

  • Operating System: osx 10.14.6
  • Node Version: 12.6.0
  • NPM Version: 6.11.3
  • webpack Version: 4.41.4
  • css-loader Version: 3.4.0

Expected Behavior

Would not prepend undefined

Actual Behavior

body{color:red}body a{color:#fff}body.open{background-color:#fef}
/*# sourceURL=undefined/src/index.scss */
...

Code

// package.json
{
    "extract-loader": "3.1.0",
    "css-loader": "3.4.0",
    "sass-loader": "8.0.0",
    "node-sass": "4.13.0",
}
// webpack config
{
  loader: 'extract-loader'
},
{
  loader: 'css-loader',
  options: {
    sourceMap: true
  }
},
{
  loader: 'sass-loader',
  options: {
    sourceMap: true,
    sassOptions: {
      sourceMapRoot: '/'
    }
  }
}

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