Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sourceMap always prepend a undefined #1034

Closed
DavidKk opened this issue Jan 1, 2020 · 0 comments · Fixed by #1036
Closed

sourceMap always prepend a undefined #1034

DavidKk opened this issue Jan 1, 2020 · 0 comments · Fixed by #1036

Comments

@DavidKk
Copy link

DavidKk commented Jan 1, 2020

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: '/'
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant