balm-core 3.33.0 → 3.33.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.
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports["default"] = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
8
  var _stream = require("stream");
10
9
  var _sass = _interopRequireDefault(require("sass"));
11
10
  var _replaceExt = _interopRequireDefault(require("replace-ext"));
@@ -125,25 +124,24 @@ var gulpSass = function gulpSass(options) {
125
124
  }
126
125
 
127
126
  // Create alias
128
- if (!opts.importer && Object.keys(BalmJS.config.scripts.alias).length) {
129
- opts.importer = [];
130
- var _loop = function _loop() {
131
- var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
132
- key = _Object$entries$_i[0],
133
- value = _Object$entries$_i[1];
134
- opts.importer.push(function (url, prev) {
135
- if (new RegExp("^".concat(key)).test(url)) {
136
- var importerPaths = url.split('/');
137
- importerPaths[0] = value;
138
- BalmJS.logger.debug("".concat(PLUGIN_NAME, " alias"), "".concat(key, " -> ").concat(importerPaths.join('/')));
139
- return {
140
- file: importerPaths.join('/')
141
- };
127
+ if (!opts.importer) {
128
+ var aliasKeys = Object.keys(BalmJS.config.scripts.alias).filter(function (key) {
129
+ return /^@\w+/.test(key);
130
+ });
131
+ if (aliasKeys.length) {
132
+ var aliasKeyRegex = new RegExp("^".concat(aliasKeys.join('|')));
133
+ opts.importer = [function (url) {
134
+ var file = url;
135
+ var result = url.match(aliasKeyRegex);
136
+ var key = result ? result[0] : null;
137
+ if (key) {
138
+ file = url.replace(aliasKeyRegex, BalmJS.config.scripts.alias[key]);
139
+ BalmJS.logger.debug("".concat(PLUGIN_NAME, " alias"), "".concat(url, " -> ").concat(file));
142
140
  }
143
- });
144
- };
145
- for (var _i = 0, _Object$entries = Object.entries(BalmJS.config.scripts.alias); _i < _Object$entries.length; _i++) {
146
- _loop();
141
+ return {
142
+ file: file
143
+ };
144
+ }];
147
145
  }
148
146
  }
149
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balm-core",
3
- "version": "3.33.0",
3
+ "version": "3.33.2",
4
4
  "description": "BalmJS compiler core",
5
5
  "keywords": [
6
6
  "balm",
@@ -119,5 +119,5 @@
119
119
  "engines": {
120
120
  "node": ">=10.13.0"
121
121
  },
122
- "gitHead": "dd9c9c8d8d0e012c4c65d3fcaddb7455354b92c0"
122
+ "gitHead": "dfd512a732f560da942949874ad21999603b2228"
123
123
  }
@@ -77,19 +77,22 @@ const gulpSass = (options) => transformObj((file, encoding, callback) => {
77
77
  opts.omitSourceMapUrl = true;
78
78
  opts.sourceMapContents = true;
79
79
  }
80
- if (!opts.importer && Object.keys(BalmJS.config.scripts.alias).length) {
81
- opts.importer = [];
82
- for (const [key, value] of Object.entries(BalmJS.config.scripts.alias)) {
83
- opts.importer.push(function (url, prev) {
84
- if (new RegExp(`^${key}`).test(url)) {
85
- const importerPaths = url.split('/');
86
- importerPaths[0] = value;
87
- BalmJS.logger.debug(`${PLUGIN_NAME} alias`, `${key} -> ${importerPaths.join('/')}`);
88
- return {
89
- file: importerPaths.join('/')
90
- };
80
+ if (!opts.importer) {
81
+ const aliasKeys = Object.keys(BalmJS.config.scripts.alias).filter((key) => /^@\w+/.test(key));
82
+ if (aliasKeys.length) {
83
+ const aliasKeyRegex = new RegExp(`^${aliasKeys.join('|')}`);
84
+ opts.importer = [
85
+ function (url) {
86
+ let file = url;
87
+ const result = url.match(aliasKeyRegex);
88
+ const key = result ? result[0] : null;
89
+ if (key) {
90
+ file = url.replace(aliasKeyRegex, BalmJS.config.scripts.alias[key]);
91
+ BalmJS.logger.debug(`${PLUGIN_NAME} alias`, `${url} -> ${file}`);
92
+ }
93
+ return { file };
91
94
  }
92
- });
95
+ ];
93
96
  }
94
97
  }
95
98
  try {