sass-loader 10.0.1 → 10.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [10.0.2](https://github.com/webpack-contrib/sass-loader/compare/v10.0.1...v10.0.2) (2020-09-03)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * source maps generation ([#886](https://github.com/webpack-contrib/sass-loader/issues/886)) ([8327d55](https://github.com/webpack-contrib/sass-loader/commit/8327d55df9e8fc6e24d2759d7bd50174ed1ff1e4))
11
+
5
12
  ### [10.0.1](https://github.com/webpack-contrib/sass-loader/compare/v10.0.0...v10.0.1) (2020-08-25)
6
13
 
7
14
  ### Chore
package/dist/index.js CHANGED
@@ -55,29 +55,18 @@ function loader(content) {
55
55
 
56
56
  callback(new _SassError.default(error));
57
57
  return;
58
- } // Modify source paths only for webpack, otherwise we do nothing
59
-
60
-
61
- if (result.map && useSourceMap) {
62
- // eslint-disable-next-line no-param-reassign
63
- result.map = JSON.parse(result.map); // result.map.file is an optional property that provides the output filename.
64
- // Since we don't know the final filename in the webpack build chain yet, it makes no sense to have it.
65
- // eslint-disable-next-line no-param-reassign
66
-
67
- delete result.map.file; // eslint-disable-next-line no-param-reassign
58
+ }
68
59
 
69
- result.sourceRoot = ''; // node-sass returns POSIX paths, that's why we need to transform them back to native paths.
70
- // This fixes an error on windows where the source-map module cannot resolve the source maps.
71
- // @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722
72
- // eslint-disable-next-line no-param-reassign
60
+ let map = result.map ? JSON.parse(result.map) : null; // Modify source paths only for webpack, otherwise we do nothing
73
61
 
74
- result.map.sources = result.map.sources.map(source => (0, _utils.absolutifySourceMapSource)(this.rootContext, source));
62
+ if (map && useSourceMap) {
63
+ map = (0, _utils.normalizeSourceMap)(map, this.rootContext);
75
64
  }
76
65
 
77
66
  result.stats.includedFiles.forEach(includedFile => {
78
67
  this.addDependency(_path.default.normalize(includedFile));
79
68
  });
80
- callback(null, result.css.toString(), result.map);
69
+ callback(null, result.css.toString(), map);
81
70
  });
82
71
  }
83
72
 
package/dist/utils.js CHANGED
@@ -8,7 +8,7 @@ exports.getSassOptions = getSassOptions;
8
8
  exports.getWebpackResolver = getWebpackResolver;
9
9
  exports.getWebpackImporter = getWebpackImporter;
10
10
  exports.getRenderFunctionFromSassImplementation = getRenderFunctionFromSassImplementation;
11
- exports.absolutifySourceMapSource = absolutifySourceMapSource;
11
+ exports.normalizeSourceMap = normalizeSourceMap;
12
12
 
13
13
  var _url = _interopRequireDefault(require("url"));
14
14
 
@@ -157,8 +157,7 @@ function getSassOptions(loaderContext, loaderOptions, content, implementation, u
157
157
  // all paths in sourceMap.sources will be relative to that path.
158
158
  // Pretty complicated... :(
159
159
  options.sourceMap = true;
160
- options.outFile = _path.default.join(loaderContext.rootContext, 'style.css.map'); // options.sourceMapRoot = process.cwd();
161
-
160
+ options.outFile = _path.default.join(loaderContext.rootContext, 'style.css.map');
162
161
  options.sourceMapContents = true;
163
162
  options.omitSourceMapUrl = true;
164
163
  options.sourceMapEmbed = false;
@@ -447,12 +446,26 @@ function getURLType(source) {
447
446
  return ABSOLUTE_SCHEME.test(source) ? 'absolute' : 'path-relative';
448
447
  }
449
448
 
450
- function absolutifySourceMapSource(sourceRoot, source) {
451
- const sourceType = getURLType(source); // Do no touch `scheme-relative`, `path-absolute` and `absolute` types
449
+ function normalizeSourceMap(map, rootContext) {
450
+ const newMap = map; // result.map.file is an optional property that provides the output filename.
451
+ // Since we don't know the final filename in the webpack build chain yet, it makes no sense to have it.
452
+ // eslint-disable-next-line no-param-reassign
452
453
 
453
- if (sourceType === 'path-relative') {
454
- return _path.default.resolve(sourceRoot, _path.default.normalize(source));
455
- }
454
+ delete newMap.file; // eslint-disable-next-line no-param-reassign
455
+
456
+ newMap.sourceRoot = ''; // node-sass returns POSIX paths, that's why we need to transform them back to native paths.
457
+ // This fixes an error on windows where the source-map module cannot resolve the source maps.
458
+ // @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722
459
+ // eslint-disable-next-line no-param-reassign
460
+
461
+ newMap.sources = newMap.sources.map(source => {
462
+ const sourceType = getURLType(source); // Do no touch `scheme-relative`, `path-absolute` and `absolute` types
456
463
 
457
- return source;
464
+ if (sourceType === 'path-relative') {
465
+ return _path.default.resolve(rootContext, _path.default.normalize(source));
466
+ }
467
+
468
+ return source;
469
+ });
470
+ return newMap;
458
471
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sass-loader",
3
- "version": "10.0.1",
3
+ "version": "10.0.2",
4
4
  "description": "Sass loader for webpack",
5
5
  "license": "MIT",
6
6
  "repository": "webpack-contrib/sass-loader",
@@ -59,13 +59,13 @@
59
59
  "klona": "^2.0.3",
60
60
  "loader-utils": "^2.0.0",
61
61
  "neo-async": "^2.6.2",
62
- "schema-utils": "^2.7.0",
62
+ "schema-utils": "^2.7.1",
63
63
  "semver": "^7.3.2"
64
64
  },
65
65
  "devDependencies": {
66
- "@babel/cli": "^7.10.5",
67
- "@babel/core": "^7.11.4",
68
- "@babel/preset-env": "^7.11.0",
66
+ "@babel/cli": "^7.11.5",
67
+ "@babel/core": "^7.11.5",
68
+ "@babel/preset-env": "^7.11.5",
69
69
  "@commitlint/cli": "^10.0.0",
70
70
  "@commitlint/config-conventional": "^10.0.0",
71
71
  "@webpack-contrib/defaults": "^6.3.0",
@@ -78,20 +78,20 @@
78
78
  "del": "^5.1.0",
79
79
  "del-cli": "^3.0.1",
80
80
  "enhanced-resolve": "^4.3.0",
81
- "eslint": "^7.7.0",
81
+ "eslint": "^7.8.1",
82
82
  "eslint-config-prettier": "^6.11.0",
83
83
  "eslint-plugin-import": "^2.21.2",
84
84
  "fibers": "^5.0.0",
85
- "file-loader": "^6.0.0",
85
+ "file-loader": "^6.1.0",
86
86
  "foundation-sites": "^6.6.3",
87
87
  "husky": "^4.2.5",
88
88
  "jest": "^26.4.2",
89
- "lint-staged": "^10.2.12",
89
+ "lint-staged": "^10.3.0",
90
90
  "material-components-web": "^7.0.0",
91
91
  "memfs": "^3.2.0",
92
92
  "node-sass": "^4.14.1",
93
93
  "npm-run-all": "^4.1.5",
94
- "prettier": "^2.1.0",
94
+ "prettier": "^2.1.1",
95
95
  "sass": "^1.26.10",
96
96
  "standard-version": "^9.0.0",
97
97
  "style-loader": "^1.2.1",