-
-
Notifications
You must be signed in to change notification settings - Fork 383
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 doesn't work with devtool option contain "eval" #529
Comments
Hi @sokra , has any solution? |
Yes, it is limitation, |
After hacking around a while, I have found that it is actually possible to have CSS source maps inlined when devtool option contains "eval". To be precise, this plugin currently only supports source maps that are emitted in separate files. In our case, this is not possible since our mini-css-extract-plugin/src/index.js Line 1410 in be75c50
... with: const result = new ConcatSource(externalsSource, source);
const m = result.map();
// if the source map information is available...
if (m != null) {
const encoded = Buffer.from(JSON.stringify(m)).toString('base64');
const footer = `/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${encoded} */`;
result.add(new RawSource(footer));
}
return result; And we have embedded the source map. Now the devtool can detect it properly. |
Follow-up: After reading webpack's source code a little bit more, I manage to adjust the configuration accordingly so it produces the inline source map instead, without touching the source code of mini-css-extract-plugin: {
/* ... */
plugins: [
new MiniCssExtractPlugin(),
new webpack.SourceMapDevToolPlugin({
test: /\.css$/i,
filename: null,
append: '/*# sourceMappingURL=[url] */',
})
]
} Normally we would turn off the This also solves issue #29 and seems more elegant than both the original and my previous solution. |
It really works! Nice solution |
Expected Behavior
Use the devtool options with "eval" such as "cheap-module-eval-source-map", the extract css file can map to the really css or sass file.

Actual Behavior
My entry file 'main.js' which import 'testSass.scss', with the devtool options "cheap-module-eval-source-map" to get the fast rebuild . But it'can not map the body style to the real sass file.

If I change devtool to "cheap-module-source-map" without 'eval', It works.
Code
How Do We Reproduce?
You can use the config above . If cannot reproduce , I will give a repo later.
Addition
I found an hack with add the sourcemapPlugin with devtools in #29 (comment)
The text was updated successfully, but these errors were encountered: