balm-core 4.30.0 → 4.32.0

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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/lib/balm.js +2 -2
  3. package/lib/bundler/webpack/config/env.js +1 -1
  4. package/lib/config/globals.js +14 -1
  5. package/lib/plugins/imagemin.js +2 -2
  6. package/lib/plugins/index.js +2 -0
  7. package/lib/plugins/postcss.js +2 -2
  8. package/lib/plugins/replace.js +1 -1
  9. package/lib/plugins/sass-legacy.js +131 -0
  10. package/lib/plugins/sass.js +66 -125
  11. package/lib/tasks/foundation/balm.js +1 -1
  12. package/lib/tasks/foundation/balm_style.js +1 -1
  13. package/lib/tasks/private/build.js +1 -1
  14. package/lib/tasks/private/cache.js +1 -1
  15. package/lib/tasks/private/clean.js +3 -3
  16. package/lib/tasks/private/end.js +1 -1
  17. package/lib/tasks/private/extra.js +1 -1
  18. package/lib/tasks/private/font.js +1 -1
  19. package/lib/tasks/private/image.js +1 -1
  20. package/lib/tasks/private/lint.js +1 -1
  21. package/lib/tasks/private/media.js +1 -1
  22. package/lib/tasks/private/modernizr.js +3 -3
  23. package/lib/tasks/private/pwa-cache.js +1 -1
  24. package/lib/tasks/private/sprite.js +2 -2
  25. package/lib/tasks/private/start.js +1 -1
  26. package/lib/tasks/private/workbox-sw.js +1 -1
  27. package/lib/tasks/public/html.js +2 -2
  28. package/lib/tasks/public/publish.js +2 -2
  29. package/lib/tasks/public/remove.js +2 -2
  30. package/lib/tasks/public/sass.js +1 -2
  31. package/lib/tasks/public/server.js +2 -2
  32. package/lib/tasks/public/url.js +2 -2
  33. package/lib/utilities/compiling.js +2 -2
  34. package/lib/utilities/loading.js +2 -2
  35. package/lib/utilities/logger.js +2 -2
  36. package/package.json +44 -43
  37. package/tslib/config/globals.js +21 -1
  38. package/tslib/plugins/imagemin.js +1 -1
  39. package/tslib/plugins/index.js +2 -0
  40. package/tslib/plugins/sass-legacy.js +95 -0
  41. package/tslib/plugins/sass.js +62 -124
  42. package/tslib/tasks/foundation/balm_style.js +3 -1
  43. package/tslib/tasks/public/sass.js +1 -2
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
4
4
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
5
5
  import mergeStream from '../../utilities/merge-stream.js';
@@ -1,4 +1,4 @@
1
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
2
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
3
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  class StartTask extends BalmJS.BalmTask {
@@ -1,4 +1,4 @@
1
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
2
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
3
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  class WorkboxSwTask extends BalmJS.BalmTask {
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
4
4
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
5
5
  import { PUBLIC_URL } from '../../config/constants.js';
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
4
4
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
5
5
  import mergeStream from '../../utilities/merge-stream.js';
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
4
4
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
5
5
  import { deleteAsync } from 'del';
@@ -1,10 +1,9 @@
1
- import { isLegacy } from '../../plugins/sass.js';
2
1
  class SassTask extends BalmJS.BalmStyleTask {
3
2
  constructor() {
4
3
  super('sass');
5
4
  }
6
5
  get options() {
7
- return Object.assign(isLegacy ? {
6
+ return Object.assign(node.isLegacySass ? {
8
7
  includePaths: BalmJS.file.stylePaths,
9
8
  outputStyle: 'expanded'
10
9
  } : {
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
4
4
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
5
5
  import detectPort from '../../utilities/detect-port.js';
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
4
4
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
5
5
  var _urlProcessing = /*#__PURE__*/new WeakMap();
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
4
4
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
5
5
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
4
4
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
5
5
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
@@ -1,5 +1,5 @@
1
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
2
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
1
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
2
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
3
3
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
4
4
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
5
5
  import util from 'node:util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balm-core",
3
- "version": "4.30.0",
3
+ "version": "4.32.0",
4
4
  "description": "BalmJS compiler core",
5
5
  "keywords": [
6
6
  "balm",
@@ -43,18 +43,18 @@
43
43
  "dependencies": {
44
44
  "@rollup/plugin-terser": "^0.4.4",
45
45
  "ansi-colors": "^4.1.3",
46
- "async": "^3.2.5",
47
- "autoprefixer": "^10.4.19",
48
- "babel-loader": "^9.1.3",
49
- "browser-sync": "^3.0.2",
46
+ "async": "^3.2.6",
47
+ "autoprefixer": "^10.4.21",
48
+ "babel-loader": "^10.0.0",
49
+ "browser-sync": "^3.0.4",
50
50
  "connect-history-api-fallback": "^2.0.0",
51
- "css-loader": "^7.1.1",
52
- "css-minimizer-webpack-plugin": "^6.0.0",
53
- "cssnano": "^7.0.1",
54
- "del": "^7.1.0",
55
- "dotenv": "^16.4.5",
56
- "dotenv-expand": "^11.0.6",
57
- "esbuild": "^0.20.0",
51
+ "css-loader": "^7.1.2",
52
+ "css-minimizer-webpack-plugin": "^7.0.2",
53
+ "cssnano": "^7.0.7",
54
+ "del": "^8.0.0",
55
+ "dotenv": "^16.5.0",
56
+ "dotenv-expand": "^12.0.2",
57
+ "esbuild": "^0.25.4",
58
58
  "fancy-log": "^2.0.0",
59
59
  "gulp-eslint": "^6.0.0",
60
60
  "gulp-if": "^3.0.0",
@@ -63,60 +63,61 @@
63
63
  "gulp-rev-delete-original": "^0.2.3",
64
64
  "gulp-size": "^5.0.0",
65
65
  "gulp-useref": "^5.0.0",
66
- "gulp-zip": "^6.0.0",
67
- "gulp.spritesmith": "^6.13.0",
68
- "html-loader": "^5.0.0",
66
+ "gulp-zip": "^6.1.0",
67
+ "gulp.spritesmith": "^6.13.1",
68
+ "html-loader": "^5.1.0",
69
69
  "html-minifier": "^4.0.0",
70
- "html-webpack-plugin": "^5.6.0",
71
- "http-proxy-middleware": "^3.0.0",
72
- "imagemin": "^9.0.0",
70
+ "html-webpack-plugin": "^5.6.3",
71
+ "http-proxy-middleware": "^3.0.5",
72
+ "imagemin": "^9.0.1",
73
73
  "istextorbinary": "^9.5.0",
74
- "less": "^4.2.0",
75
- "mini-css-extract-plugin": "^2.9.0",
76
- "modernizr": "^3.13.0",
74
+ "less": "^4.3.0",
75
+ "mini-css-extract-plugin": "^2.9.2",
76
+ "modernizr": "^3.13.1",
77
77
  "parents": "^1.0.1",
78
78
  "plugin-error": "^2.0.1",
79
- "postcss": "^8.4.38",
79
+ "postcss": "^8.5.3",
80
80
  "postcss-flexbugs-fixes": "^5.0.2",
81
81
  "postcss-import": "^16.1.0",
82
- "postcss-load-config": "^5.1.0",
82
+ "postcss-load-config": "^6.0.1",
83
83
  "postcss-loader": "^8.1.1",
84
- "postcss-preset-env": "^9.5.11",
85
- "pretty-bytes": "^6.1.1",
86
- "readable-stream": "^4.5.2",
84
+ "postcss-preset-env": "^10.1.6",
85
+ "pretty-bytes": "^7.0.0",
86
+ "readable-stream": "^4.7.0",
87
87
  "replace-ext": "^2.0.0",
88
- "rollup": "^4.17.2",
89
- "sass": "^1.77.0",
90
- "sass-loader": "^14.2.1",
91
- "semver": "^7.6.0",
92
- "ssh2": "^1.15.0",
88
+ "rollup": "^4.41.0",
89
+ "sass": "^1.89.0",
90
+ "sass-loader": "^16.0.5",
91
+ "semver": "^7.7.2",
92
+ "ssh2": "^1.16.0",
93
93
  "strip-ansi": "^7.1.0",
94
94
  "style-loader": "^4.0.0",
95
- "tailwindcss": "^3.4.3",
96
- "terser": "^5.31.0",
97
- "terser-webpack-plugin": "^5.3.10",
95
+ "tailwindcss": "^4.1.7",
96
+ "terser": "^5.39.2",
97
+ "terser-webpack-plugin": "^5.3.14",
98
98
  "through2": "^4.0.2",
99
99
  "through2-concurrent": "^2.0.0",
100
- "tslib": "^2.6.2",
100
+ "tslib": "^2.8.1",
101
101
  "vinyl-sourcemaps-apply": "^0.2.1",
102
- "webpack": "^5.91.0",
102
+ "webpack": "^5.99.8",
103
103
  "webpack-bundle-analyzer": "^4.10.2",
104
- "webpack-dev-middleware": "^7.2.1",
104
+ "webpack-dev-middleware": "^7.4.2",
105
105
  "webpack-hot-middleware": "^2.26.1",
106
- "webpack-merge": "^5.10.0",
107
- "workbox-build": "^7.1.0"
106
+ "webpack-merge": "^6.0.1",
107
+ "workbox-build": "^7.3.0"
108
108
  },
109
109
  "devDependencies": {
110
110
  "@types/async": "3",
111
111
  "@types/browser-sync": "2",
112
- "@types/express": "4",
112
+ "@types/express": "5",
113
113
  "@types/fancy-log": "2",
114
114
  "@types/html-minifier": "4",
115
- "@types/imagemin": "8",
115
+ "@types/imagemin": "9",
116
116
  "@types/parents": "1",
117
117
  "@types/postcss-flexbugs-fixes": "5",
118
118
  "@types/readable-stream": "4",
119
119
  "@types/replace-ext": "2",
120
+ "@types/semver": "7",
120
121
  "@types/through2-concurrent": "2",
121
122
  "@types/webpack-bundle-analyzer": "4",
122
123
  "@types/webpack-hot-middleware": "2"
@@ -128,7 +129,7 @@
128
129
  "imagemin-svgo": "^9.0.0"
129
130
  },
130
131
  "engines": {
131
- "node": ">=18.12.0"
132
+ "node": "^20.10.0 || >=22.0.0"
132
133
  },
133
- "gitHead": "55b2193b43739c624bd7d3e3f927b114724883ea"
134
+ "gitHead": "0bfe647d62456b11dfbc8a27f533db5d9f109e31"
134
135
  }
@@ -4,8 +4,26 @@ import colors from 'ansi-colors';
4
4
  import { create } from 'browser-sync';
5
5
  import through2 from 'through2';
6
6
  import PluginError from 'plugin-error';
7
+ import semver from 'semver';
7
8
  process.env.BALM_CWD = process.env.INIT_CWD || process.cwd();
8
9
  const gulpModule = path.join(process.env.BALM_ROOT || process.env.BALM_CWD, 'node_modules', 'gulp', 'index.js');
10
+ const localSassModule = path.join(process.env.BALM_CWD, 'node_modules', 'sass');
11
+ let isLegacySass = false;
12
+ try {
13
+ const sassPkg = requireModule(path.join(localSassModule, 'package.json'));
14
+ isLegacySass = semver.lt(sassPkg.version, '1.40.0');
15
+ }
16
+ catch (_) { }
17
+ const nodeLocalSassModule = path.join(localSassModule, 'sass.node.js');
18
+ const defaultLocalSassModule = path.join(localSassModule, 'sass.default.js');
19
+ const dartLocalSassModule = path.join(localSassModule, 'sass.dart.js');
20
+ const getSassModule = (sass) => fs.existsSync(nodeLocalSassModule)
21
+ ? requireModule(nodeLocalSassModule)
22
+ : fs.existsSync(defaultLocalSassModule)
23
+ ? requireModule(defaultLocalSassModule)
24
+ : fs.existsSync(dartLocalSassModule)
25
+ ? requireModule(dartLocalSassModule)
26
+ : sass;
9
27
  if (fs.existsSync(gulpModule)) {
10
28
  if (process.cwd() !== process.env.BALM_CWD) {
11
29
  process.chdir(process.env.BALM_CWD);
@@ -19,7 +37,9 @@ else {
19
37
  }
20
38
  global.node = {
21
39
  path,
22
- fs
40
+ fs,
41
+ isLegacySass,
42
+ getSassModule
23
43
  };
24
44
  global.server = create();
25
45
  global.through2 = through2;
@@ -55,7 +55,7 @@ function gulpImagemin(customPlugins) {
55
55
  totalFiles++;
56
56
  }
57
57
  BalmJS.logger.debug(PLUGIN_NAME, `${file.relative} (${message})`);
58
- file.contents = data;
58
+ file.contents = Buffer.from(data);
59
59
  callback(null, file);
60
60
  }
61
61
  catch (error) {
@@ -8,6 +8,7 @@ import postcssPlugins from './postcss-plugins.js';
8
8
  import rename from './rename.js';
9
9
  import replace from './replace.js';
10
10
  import sass from './sass.js';
11
+ import legacySass from './sass-legacy.js';
11
12
  import sftp from './sftp.js';
12
13
  const plugins = {
13
14
  htmlmin,
@@ -20,6 +21,7 @@ const plugins = {
20
21
  rename,
21
22
  replace,
22
23
  sass,
24
+ legacySass,
23
25
  sftp
24
26
  };
25
27
  BalmJS.plugins = plugins;
@@ -0,0 +1,95 @@
1
+ import { Transform } from 'node:stream';
2
+ import * as sass from 'sass';
3
+ import replaceExtension from 'replace-ext';
4
+ import stripAnsi from 'strip-ansi';
5
+ import applySourceMap from 'vinyl-sourcemaps-apply';
6
+ import ansiColors from 'ansi-colors';
7
+ const sassModule = node.getSassModule(sass);
8
+ const PLUGIN_NAME = 'sass-legacy';
9
+ const transformObj = (transform) => new Transform({ transform, objectMode: true });
10
+ function filePush(file, sassObject, callback) {
11
+ if (sassObject.map) {
12
+ const sassMap = JSON.parse(sassObject.map.toString());
13
+ const sassMapFile = sassMap.file.replace(/^stdout$/, 'stdin');
14
+ const sassFileSrc = file.relative;
15
+ const sassFileSrcPath = node.path.dirname(sassFileSrc);
16
+ if (sassFileSrcPath) {
17
+ const sourceFileIndex = sassMap.sources.indexOf(sassMapFile);
18
+ sassMap.sources = sassMap.sources.map((source, index) => index === sourceFileIndex
19
+ ? source
20
+ : node.path.join(sassFileSrcPath, source));
21
+ }
22
+ sassMap.sources = sassMap.sources.filter((src) => src !== 'stdin' && src);
23
+ sassMap.file = replaceExtension(sassFileSrc, '.css');
24
+ applySourceMap(file, sassMap);
25
+ }
26
+ file.contents = sassObject.css;
27
+ file.path = replaceExtension(file.path, '.css');
28
+ if (file.stat) {
29
+ file.stat.atime = file.stat.mtime = file.stat.ctime = new Date();
30
+ }
31
+ callback(null, file);
32
+ }
33
+ function handleError(error, file, callback) {
34
+ const filePath = (error.file === 'stdin' ? file.path : error.file) || file.path;
35
+ const relativePath = node.path.relative(process.cwd(), filePath);
36
+ const message = `${ansiColors.underline(relativePath)}\n${error.formatted}`;
37
+ error.messageFormatted = message;
38
+ error.messageOriginal = error.message;
39
+ error.message = stripAnsi(message);
40
+ error.relativePath = relativePath;
41
+ return callback(new PluginError(PLUGIN_NAME, error));
42
+ }
43
+ const gulpSass = (options, sync = false) => transformObj((file, encoding, callback) => {
44
+ if (file.isNull()) {
45
+ return callback(null, file);
46
+ }
47
+ if (file.isStream()) {
48
+ return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
49
+ }
50
+ if (node.path.basename(file.path).startsWith('_')) {
51
+ return callback();
52
+ }
53
+ if (!file.contents.length) {
54
+ file.path = replaceExtension(file.path, '.css');
55
+ return callback(null, file);
56
+ }
57
+ const opts = (options || {});
58
+ opts.data = file.contents.toString();
59
+ opts.file = file.path;
60
+ if (node.path.extname(file.path) === '.sass') {
61
+ opts.indentedSyntax = true;
62
+ }
63
+ if (opts.includePaths) {
64
+ if (typeof opts.includePaths === 'string') {
65
+ opts.includePaths = [opts.includePaths];
66
+ }
67
+ }
68
+ else {
69
+ opts.includePaths = [];
70
+ }
71
+ opts.includePaths.unshift(node.path.dirname(file.path));
72
+ if (file.sourceMap) {
73
+ opts.sourceMap = file.path;
74
+ opts.omitSourceMapUrl = true;
75
+ opts.sourceMapContents = true;
76
+ }
77
+ if (sync !== true) {
78
+ sassModule.render(opts, (error, obj) => {
79
+ if (error) {
80
+ handleError(error, file, callback);
81
+ return;
82
+ }
83
+ filePush(file, obj, callback);
84
+ });
85
+ }
86
+ else {
87
+ try {
88
+ filePush(file, sassModule.renderSync(opts), callback);
89
+ }
90
+ catch (error) {
91
+ handleError(error, file, callback);
92
+ }
93
+ }
94
+ });
95
+ export default gulpSass;