@bigcommerce/stencil-cli 8.2.0 → 8.3.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.
- package/lib/css/compile.js +2 -5
- package/lib/stencil-bundle.js +5 -4
- package/package.json +2 -2
- package/lib/css-assembler.js +0 -99
package/lib/css/compile.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const StencilStyles = require('@bigcommerce/stencil-styles');
|
|
3
|
-
const { promisify } = require('util');
|
|
4
|
-
|
|
5
|
-
const cssAssembler = require('../css-assembler');
|
|
6
3
|
|
|
7
4
|
const SASS_ENGINE_NAME = 'node-sass';
|
|
8
5
|
|
|
@@ -11,10 +8,11 @@ const compile = async (configuration, themeAssetsPath, fileName, engineName = SA
|
|
|
11
8
|
const ext = configuration.css_compiler === 'css' ? configuration.css_compiler : 'scss';
|
|
12
9
|
const pathToFile = path.join(fileParts.dir, `${fileParts.name}.${ext}`);
|
|
13
10
|
const basePath = path.join(themeAssetsPath, `${ext}`);
|
|
11
|
+
const stencilStyles = new StencilStyles(console);
|
|
14
12
|
|
|
15
13
|
let files;
|
|
16
14
|
try {
|
|
17
|
-
files = await
|
|
15
|
+
files = await stencilStyles.assembleCssFiles(pathToFile, basePath, `${ext}`, {});
|
|
18
16
|
} catch (err) {
|
|
19
17
|
console.error(err);
|
|
20
18
|
throw err;
|
|
@@ -31,7 +29,6 @@ const compile = async (configuration, themeAssetsPath, fileName, engineName = SA
|
|
|
31
29
|
overrideBrowserslist: configuration.autoprefixer_browsers,
|
|
32
30
|
},
|
|
33
31
|
};
|
|
34
|
-
const stencilStyles = new StencilStyles(console);
|
|
35
32
|
stencilStyles.activateEngine(engineName);
|
|
36
33
|
|
|
37
34
|
return stencilStyles.compileCss('scss', params);
|
package/lib/stencil-bundle.js
CHANGED
|
@@ -4,11 +4,11 @@ const async = require('async');
|
|
|
4
4
|
const crypto = require('crypto');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const StencilStyles = require('@bigcommerce/stencil-styles');
|
|
7
8
|
|
|
8
9
|
const BuildConfigManager = require('./BuildConfigManager');
|
|
9
10
|
const BundleValidator = require('./bundle-validator');
|
|
10
11
|
const Cycles = require('./Cycles');
|
|
11
|
-
const cssAssembler = require('./css-assembler');
|
|
12
12
|
const langAssembler = require('./lang-assembler');
|
|
13
13
|
const templateAssembler = require('./template-assembler');
|
|
14
14
|
const { recursiveReadDir } = require('./utils/fsUtils');
|
|
@@ -37,6 +37,8 @@ const PATHS_TO_ZIP = [
|
|
|
37
37
|
{ pattern: 'webpack.*.js' },
|
|
38
38
|
];
|
|
39
39
|
|
|
40
|
+
const stencilStyles = new StencilStyles();
|
|
41
|
+
|
|
40
42
|
class Bundle {
|
|
41
43
|
constructor(
|
|
42
44
|
themePath,
|
|
@@ -126,13 +128,12 @@ class Bundle {
|
|
|
126
128
|
});
|
|
127
129
|
async.map(
|
|
128
130
|
filterFiles,
|
|
129
|
-
(file
|
|
130
|
-
|
|
131
|
+
async (file) => {
|
|
132
|
+
return stencilStyles.assembleCssFiles(
|
|
131
133
|
file,
|
|
132
134
|
basePath,
|
|
133
135
|
compiler,
|
|
134
136
|
assembleOptions,
|
|
135
|
-
mapCallback,
|
|
136
137
|
);
|
|
137
138
|
},
|
|
138
139
|
(assemblingError, results) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigcommerce/stencil-cli",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "CLI tool to run BigCommerce Stores locally for theme development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@bigcommerce/stencil-paper": "5.0.0",
|
|
52
|
-
"@bigcommerce/stencil-styles": "
|
|
52
|
+
"@bigcommerce/stencil-styles": "^6.1.1",
|
|
53
53
|
"@hapi/boom": "^10.0.0",
|
|
54
54
|
"@hapi/glue": "^8.0.0",
|
|
55
55
|
"@hapi/h2o2": "^9.1.0",
|
package/lib/css-assembler.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const async = require('async');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const upath = require('upath');
|
|
5
|
-
|
|
6
|
-
const importRegex = /@import\s+?["'](.+?)["'];/g;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Parses all of the imports for SCSS files and returns a flat object with the file path as the key and
|
|
10
|
-
* file content as the value.
|
|
11
|
-
*
|
|
12
|
-
* @param cssFiles
|
|
13
|
-
* @param absolutePath
|
|
14
|
-
* @param type - scss
|
|
15
|
-
* @param options - options object
|
|
16
|
-
* @param callback
|
|
17
|
-
*/
|
|
18
|
-
function assemble(cssFiles, absolutePath, type, options, callback) {
|
|
19
|
-
const ret = {};
|
|
20
|
-
const ext = `.${type}`;
|
|
21
|
-
|
|
22
|
-
const cssFilesArr = Array.isArray(cssFiles) ? cssFiles : [cssFiles];
|
|
23
|
-
|
|
24
|
-
const parseImports = (cssFileAlias, parseImportsCallback) => {
|
|
25
|
-
const normalizedCssFileAlias = cssFileAlias.replace(/(\.scss)$/g, '');
|
|
26
|
-
const typedCssFilePath = path.join(absolutePath, normalizedCssFileAlias + ext);
|
|
27
|
-
const rawCssFilePath = path.join(absolutePath, normalizedCssFileAlias + '.css');
|
|
28
|
-
const cssFileAliasDir = path.parse(normalizedCssFileAlias).dir;
|
|
29
|
-
|
|
30
|
-
const fileParts = path.parse(typedCssFilePath);
|
|
31
|
-
const underscoredFilePath = path.join(fileParts.dir, `_${fileParts.base}`);
|
|
32
|
-
let filePath;
|
|
33
|
-
|
|
34
|
-
if (fs.existsSync(typedCssFilePath)) {
|
|
35
|
-
filePath = typedCssFilePath;
|
|
36
|
-
} else if (fs.existsSync(underscoredFilePath)) {
|
|
37
|
-
filePath = underscoredFilePath;
|
|
38
|
-
} else if (ext === '.scss' && fs.existsSync(rawCssFilePath)) {
|
|
39
|
-
filePath = rawCssFilePath;
|
|
40
|
-
} else {
|
|
41
|
-
// File doesn't exist, just return to skip it
|
|
42
|
-
parseImportsCallback();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
fs.readFile(filePath, { encoding: 'utf-8' }, (err, content) => {
|
|
47
|
-
const matches = [];
|
|
48
|
-
let match;
|
|
49
|
-
let importCssFileAlias;
|
|
50
|
-
|
|
51
|
-
if (!err) {
|
|
52
|
-
// Ensure all import paths are Unix paths for prod compat.
|
|
53
|
-
const cssFile = options.bundle
|
|
54
|
-
? upath.toUnix(normalizedCssFileAlias + ext)
|
|
55
|
-
: normalizedCssFileAlias + ext;
|
|
56
|
-
|
|
57
|
-
ret[cssFile] = content;
|
|
58
|
-
match = importRegex.exec(content);
|
|
59
|
-
|
|
60
|
-
while (match !== null) {
|
|
61
|
-
[, importCssFileAlias] = match;
|
|
62
|
-
if (cssFileAliasDir) {
|
|
63
|
-
importCssFileAlias = path.join(cssFileAliasDir, importCssFileAlias);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!ret[importCssFileAlias + ext]) {
|
|
67
|
-
matches.push(importCssFileAlias);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
match = importRegex.exec(content);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async.each(matches, parseImports, parseImportsCallback);
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
async.map(
|
|
79
|
-
cssFilesArr,
|
|
80
|
-
(cssFile, mapCallback) => {
|
|
81
|
-
const cssFileParts = path.parse(cssFile);
|
|
82
|
-
const cssFileAlias = path.join(cssFileParts.dir, cssFileParts.name);
|
|
83
|
-
|
|
84
|
-
parseImports(cssFileAlias, mapCallback);
|
|
85
|
-
},
|
|
86
|
-
(err) => {
|
|
87
|
-
if (err) {
|
|
88
|
-
callback(err);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
callback(null, ret);
|
|
93
|
-
},
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
module.exports = {
|
|
98
|
-
assemble,
|
|
99
|
-
};
|