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

extract-loader and css-loader sourceMap is undefined #70

Closed
DavidKk opened this issue Jan 1, 2020 · 1 comment
Closed

extract-loader and css-loader sourceMap is undefined #70

DavidKk opened this issue Jan 1, 2020 · 1 comment

Comments

@DavidKk
Copy link

DavidKk commented Jan 1, 2020

Issue

i use extract-loader and css-loader to generate source map, but the sourceURL always prepend aundefined

body{color:red}body a{color:#fff}body.open{background-color:#fef}

/*# sourceURL=undefined/src/index.scss */
...

Reason

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

I look for some codes, and found that https://github.com/peerigon/extract-loader/blob/master/src/extractLoader.js#L141, it uses extractExports function to transform, (Function toString()) sandbox.module.exports; And the css-loader (webpack-contrib/css-loader#674 (comment)) use cssWithMappingToString and the variables cssMapping.sourceRoot to concat string, but https://github.com/webpack-contrib/css-loader/blob/master/src/index.js#L76 has been remove the sourceRoot, so that extract-loader can not found sourceRoot anymore, and sourceRoot always to undefined

Suggest

I suggest extract-loader can compatibles it, when the sourceRoot is undefined

Environment

My package.jsonand webpack config below:

// package.json
{
    "extract-loader": "^3.1.0",
    "css-loader": "^3.4.0",
}
// webpack config
{
  loader: 'extract-loader'
},
{
  loader: 'css-loader',
  options: {
    sourceMap: true
  }
},
{
  loader: 'sass-loader',
  options: {
    sourceMap: true,
    sassOptions: {
      sourceMapRoot: '/'
    }
  }
}
@DavidKk
Copy link
Author

DavidKk commented Jan 1, 2020

Report wrong place, i have been forward to css-loader... webpack-contrib/css-loader#1034

@DavidKk DavidKk closed this as completed Jan 1, 2020
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

No branches or pull requests

1 participant