-
-
Notifications
You must be signed in to change notification settings - Fork 428
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 paths fail because of overriden sourceMap option. #484
Comments
@baunegaard your can set |
@evilebottnawi just tried that. Makes no difference. Paths are still mangled. Will try to put up a test repo. |
@evilebottnawi // Dont override sourceMap option if a specific path is given.
if (typeof options.sourceMap === "boolean") {
// Deliberately overriding the sourceMap option here.
// node-sass won't produce source maps if the data option is used and options.sourceMap is not a string.
// In case it is a string, options.sourceMap should be a path where the source map is written.
// But since we're using the data option, the source map will not actually be written, but
// all paths in sourceMap.sources will be relative to that path.
// Pretty complicated... :(
options.sourceMap = path.join(process.cwd(), "/sass.map");
} With a minimal test repo do you mean just an empty repo with a webpack.config to reproduce? Or a pull request with tests inside the sass-loader repo? Sorry not that used to doing open source development :) |
@baunegaard
|
@evilebottnawi I have reproduced the problem in the following repo: The mangled path looks like this in chrome: Apply the fix from the OP and problem is gone. |
@baunegaard Did not understand what expected behavior? |
@evilebottnawi No look at the path to the sourcemap in the screenshot: "./css/bundles/css/modules/module.scss" This is not correct. The correct path should be "./css/modules/module.scss" If you look at the repo, the directory structure is:
The webpack entry point is "<Project Root>/css/bundles/bundle.scss" which has two imports: node_modules resolve correct. |
@baunegaard thanks for clarify, try to found solution in near future |
@baunegaard Your issue is that |
We can fix it change But it is should be work with relative path, seems problems not in [ 'css/bundles/bundle.scss', 'css/modules/module.scss' ]
[ 'node_modules/bootstrap/dist/css/bootstrap.css' ] |
Using (here https://github.com/webpack-contrib/sass-loader/blob/master/lib/loader.js#L73): console.log(result.map.sourceRoot)
console.log(result.map.sources) Output: /home/evilebottnawi/IdeaProjects/sass-loader-sourcemap-test
[ 'css/bundles/bundle.scss', 'css/modules/module.scss' ]
/home/evilebottnawi/IdeaProjects/sass-loader-sourcemap-test
[ 'node_modules/bootstrap/dist/css/bootstrap.css' ] All fine, seems issue related to |
@michael-ciniawsky Tried moving config to project root. Did not make a difference.
As a temporary workaround i used adjust-sourcemap-loader to fix the paths. Now my only problem is that stars (*) gets appended to some of the source map sources somewhere in the chain. This does not break sourcemaps in general, but it does break Chrome DevTool Workspaces as it wont map to the original files. |
@baunegaard related to |
@evilebottnawi I finally got source maps working! from: options.from, thereby allowing path rewriting of sources in css-loader, all problems were fixed! I now have correct paths to all sourcemaps, even without my first change to sass-loader. So the problem definitely seems to be in css-loader. Only thing was 2 extra duplicate source maps located in the root. var templateFn = require("adjust-sourcemap-loader")
.moduleFilenameTemplate(
{
format: "webpackProtocol"
}); and changing webpack.config.js output to: devtoolModuleFilenameTemplate: templateFn,
devtoolFallbackModuleFilenameTemplate: templateFn eveything now looks perfect! No duplicate sourcemaps and all sourcemap paths are correct. |
Close here because not related to |
I have a folder structure like this:
Webpack is run from <Project root> with the config file residing in <Project root>/Assets
In normalizeOptions.js the sourceMap option is overriden like this:
All SourceMap paths of imported files look like this:
./Assets/css/bundles/Assets/css/modules/utils/_mixins.scss
This is very wrong.
If i comment out that line and set sourceMap option manually, i can get sourceMaps to work:
SourceMap paths now look correct:
./Assets/css/modules/utils/_mixins.scss
The text was updated successfully, but these errors were encountered: