@adamlui/scss-to-css 1.5.0 → 1.5.1
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/README.md +6 -5
- package/docs/LICENSE.md +4 -16
- package/package.json +1 -1
- package/scss-to-css.js +38 -35
package/README.md
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
### Recursively compile all SCSS files into minified CSS.
|
|
4
4
|
|
|
5
5
|
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dt/%40adamlui%2Fscss-to-css?logo=npm&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
6
|
-
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-
|
|
7
|
-
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.
|
|
8
|
-
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fscss-to-css?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646"></a>
|
|
6
|
+
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-red.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.1-fc7811.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
8
|
+
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fscss-to-css?style=for-the-badge&logo=ebox&logoColor=white&color=blue&labelColor=464646"></a>
|
|
9
|
+
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:scss-to-css/scss-to-css.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ascss-to-css%2Fscss-to-css.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
9
10
|
|
|
10
11
|
<img height=8px width="100%" src="https://github.com/adamlui/js-utils/blob/main/docs/images/aqua-separator.png">
|
|
11
12
|
|
|
@@ -50,7 +51,7 @@ scss-to-css [input_path] [output_path]
|
|
|
50
51
|
- `[input_path]`: Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory.
|
|
51
52
|
- `[output_path]`: Path to file or directory where CSS + sourcemap files will be stored, relative to original file location (if not provided, `css/` is used).
|
|
52
53
|
|
|
53
|
-
**💡 Note:** If folders are passed, files will be processed recursively. To include dotfolders, pass `-
|
|
54
|
+
**💡 Note:** If folders are passed, files will be processed recursively. To include dotfolders, pass `-d` or `--include-dotfolders`.
|
|
54
55
|
|
|
55
56
|
#
|
|
56
57
|
|
|
@@ -96,7 +97,7 @@ Replace `<scss-to-css-cmd>` with `scss-to-css` + optional args. Then, `npm run b
|
|
|
96
97
|
|
|
97
98
|
## 💖 Support
|
|
98
99
|
|
|
99
|
-
Please consider giving a ⭐
|
|
100
|
+
Please consider [giving a GitHub ⭐](https://github.com/adamlui/js-utils) if this helped you!
|
|
100
101
|
<br><br>
|
|
101
102
|
|
|
102
103
|
## 🏛️ MIT License
|
package/docs/LICENSE.md
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
# MIT License
|
|
1
|
+
# 🏛️ MIT License
|
|
2
2
|
|
|
3
3
|
**Copyright (c) 2024 [Adam Lui](https://github.com/adamlui)**
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
6
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
14
8
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
package/scss-to-css.js
CHANGED
|
@@ -11,27 +11,39 @@ const nc = '\x1b[0m', // no color
|
|
|
11
11
|
by = '\x1b[1;33m', // bright yellow
|
|
12
12
|
bg = '\x1b[1;92m'; // bright green
|
|
13
13
|
|
|
14
|
+
// Load FLAG settings
|
|
15
|
+
const config = {
|
|
16
|
+
dryRun: process.argv.some(arg => /^--?(?:n|dry-?run)$/.test(arg)),
|
|
17
|
+
includeDotFolders: process.argv.some(arg =>
|
|
18
|
+
/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?)$/.test(arg)),
|
|
19
|
+
disableSourceMaps: process.argv.some(arg =>
|
|
20
|
+
/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?)$/.test(arg)),
|
|
21
|
+
noMinify: process.argv.some(arg =>
|
|
22
|
+
/^--?(?:M|(?:disable|no)-?minif(?:y|ication))$/.test(arg)),
|
|
23
|
+
quietMode: process.argv.some(arg => /^--?q(?:uiet)?$/.test(arg))
|
|
24
|
+
};
|
|
25
|
+
|
|
14
26
|
// Show HELP screen if -h or --help passed
|
|
15
27
|
if (process.argv.some(arg => /^--?h(?:elp)?$/.test(arg))) {
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
printWrappedMsg(' [inputPath] '
|
|
29
|
+
printHelp(`\n${by}scss-to-css [inputPath] [outputPath] [options]${nc}`);
|
|
30
|
+
printHelp('\nPath arguments:');
|
|
31
|
+
printHelp(' [inputPath] '
|
|
21
32
|
+ 'Path to SCSS file or directory containing SCSS files to be compiled,'
|
|
22
33
|
+ ' relative to the current working directory.');
|
|
23
|
-
|
|
34
|
+
printHelp(' [outputPath] '
|
|
24
35
|
+ 'Path to file or directory where CSS + sourcemap files will be stored,'
|
|
25
36
|
+ ' relative to original file location (if not provided, css/ is used).');
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
printHelp('\nConfig options:');
|
|
38
|
+
printHelp(' -n, --dry-run Don\'t actually compile the file(s),'
|
|
28
39
|
+ ' just show if they will be processed.');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
printHelp(' -d, --include-dotfolders Include dotfolders in file search.');
|
|
41
|
+
printHelp(' -S, --disable-source-maps Prevent source maps from being generated.');
|
|
42
|
+
printHelp(' -M, --no-minify Disable minification of output CSS.');
|
|
43
|
+
printHelp(' -q, --quiet Suppress all logging except errors.');
|
|
44
|
+
printHelp('\nInfo commands:');
|
|
45
|
+
printHelp(' -h, --help Display this help screen.');
|
|
46
|
+
printHelp(' -v, --version Show version number.');
|
|
35
47
|
|
|
36
48
|
// Show VERSION number if -v or --version passed
|
|
37
49
|
} else if (process.argv.some(arg => /^--?ve?r?s?i?o?n?$/.test(arg))) {
|
|
@@ -56,17 +68,6 @@ if (process.argv.some(arg => /^--?h(?:elp)?$/.test(arg))) {
|
|
|
56
68
|
process.exit(1);
|
|
57
69
|
}
|
|
58
70
|
|
|
59
|
-
// Load flag settings
|
|
60
|
-
const config = {
|
|
61
|
-
dryRun: process.argv.some(arg => /^--?(?:n|dry-?run)$/.test(arg)),
|
|
62
|
-
includeDotFolders: process.argv.some(arg =>
|
|
63
|
-
/^--?(?:dd|(?:include-)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?)$/.test(arg)),
|
|
64
|
-
disableSourceMaps: process.argv.some(arg =>
|
|
65
|
-
/^--?(?:S|(?:exclude|disable)-so?u?rce?-?maps?)$/.test(arg)),
|
|
66
|
-
noMinify: process.argv.some(arg =>
|
|
67
|
-
/^--?(?:M|(?:disable|no)-minif(?:y|ication))$/.test(arg))
|
|
68
|
-
};
|
|
69
|
-
|
|
70
71
|
// Recursively find all eligible SCSS files or arg-passed file
|
|
71
72
|
const scssFiles = [];
|
|
72
73
|
if (inputArg.endsWith('.scss')) scssFiles.push(inputPath);
|
|
@@ -83,7 +84,7 @@ if (process.argv.some(arg => /^--?h(?:elp)?$/.test(arg))) {
|
|
|
83
84
|
})(inputPath);
|
|
84
85
|
|
|
85
86
|
if (scssFiles.length === 0) { // print nothing found
|
|
86
|
-
|
|
87
|
+
printIfNotQuiet(`\n${by}No SCSS files found.${nc}`);
|
|
87
88
|
|
|
88
89
|
} else if (config.dryRun) { // print files to be processed
|
|
89
90
|
console.info(`\n${by}SCSS files to be compiled:${nc}`);
|
|
@@ -92,10 +93,10 @@ if (process.argv.some(arg => /^--?h(?:elp)?$/.test(arg))) {
|
|
|
92
93
|
} else { // actually compile SCSS files
|
|
93
94
|
|
|
94
95
|
let cssGenCnt = 0, srcMapGenCnt = 0;
|
|
95
|
-
|
|
96
|
+
printIfNotQuiet(''); // line break before first log
|
|
96
97
|
scssFiles.forEach(scssPath => {
|
|
97
|
-
|
|
98
|
-
try { // to compile
|
|
98
|
+
printIfNotQuiet(`Compiling ${ scssPath }...`);
|
|
99
|
+
try { // to compile SCSS file
|
|
99
100
|
const outputDir = path.join(
|
|
100
101
|
path.dirname(scssPath), // path of file to be minified
|
|
101
102
|
/(?:src|s[ac]ss)$/.test(path.dirname(scssPath)) ? '../css' // + ../css/ if in *(src|sass|scss)/
|
|
@@ -117,22 +118,22 @@ if (process.argv.some(arg => /^--?h(?:elp)?$/.test(arg))) {
|
|
|
117
118
|
fs.writeFileSync(outputPath + '.map', JSON.stringify(compileResult.sourceMap), 'utf8');
|
|
118
119
|
srcMapGenCnt++;
|
|
119
120
|
}
|
|
120
|
-
} catch (err) {
|
|
121
|
-
console.error(`${br}Error compiling ${ scssPath }: ${ err.message }${nc}`);
|
|
122
|
-
}
|
|
121
|
+
} catch (err) { console.error(`${br}Error compiling ${ scssPath }: ${ err.message }${nc}`); }
|
|
123
122
|
});
|
|
124
123
|
|
|
125
124
|
// Print final summary
|
|
126
125
|
if (cssGenCnt) {
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
printIfNotQuiet(`\n${bg}Compilation complete!${nc}`);
|
|
127
|
+
printIfNotQuiet(`${ cssGenCnt } CSS file${ cssGenCnt > 1 ? 's' : '' }`
|
|
129
128
|
+ ( srcMapGenCnt ? ` + ${ srcMapGenCnt } source map${ srcMapGenCnt > 1 ? 's' : '' }` : '' )
|
|
130
129
|
+ ' generated.');
|
|
131
|
-
} else
|
|
130
|
+
} else printIfNotQuiet(`${by}No SCSS files processed successfully.${nc}`);
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
|
|
134
|
+
// Define LOGGING functions
|
|
135
|
+
|
|
136
|
+
function printHelp(msg) { // wrap msg + indent 2nd+ lines (for --help screen)
|
|
136
137
|
const terminalWidth = process.stdout.columns || 80,
|
|
137
138
|
indentation = 30, lines = [], words = msg.match(/\S+|\s+/g);
|
|
138
139
|
|
|
@@ -154,3 +155,5 @@ function printWrappedMsg(msg) { // wraps msg, indents 2nd+ lines
|
|
|
154
155
|
: ' '.repeat(indentation) + line // print subsequent lines indented
|
|
155
156
|
));
|
|
156
157
|
}
|
|
158
|
+
|
|
159
|
+
function printIfNotQuiet(msg) { if (!config.quietMode) console.info(msg); }
|