@adamlui/scss-to-css 1.9.0 โ 1.10.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 +24 -18
- package/dist/cli.min.js +12 -10
- package/dist/scss-to-css.min.js +1 -1
- package/docs/README.md +24 -18
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
31
31
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
32
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.
|
|
32
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.10.1"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.10.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
33
33
|
<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>
|
|
34
34
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:node.js/src/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_scss-to-css%3Anode.js%2Fsrc%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>
|
|
35
35
|
<a href="https://github.com/toolleeo/cli-apps#conversion"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
@@ -58,6 +58,8 @@ $ npm install @adamlui/scss-to-css
|
|
|
58
58
|
|
|
59
59
|
<br>
|
|
60
60
|
|
|
61
|
+
<a href="https://github.com/sponsors/adamlui"><img src="https://media.scsstocss.org/images/banners/sponsor/$10/banner1660x260.png?2cba0ae"></a>
|
|
62
|
+
|
|
61
63
|
<img height=6px width="100%" src="https://media.scsstocss.org/images/separators/gradient-aqua.png?52b67bc">
|
|
62
64
|
|
|
63
65
|
## ๐ป Command line usage
|
|
@@ -72,7 +74,7 @@ Sample output:
|
|
|
72
74
|
|
|
73
75
|
<img src="https://cdn.jsdelivr.net/gh/adamlui/scss-to-css@b74edea/node.js/media/images/screenshots/cli/scss-to-css-docs-cmd-output.png">
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
**๐ Note:** Source maps are also generated by default unless `-S` or `--no-source-maps` is passed.
|
|
76
78
|
|
|
77
79
|
#
|
|
78
80
|
|
|
@@ -85,7 +87,7 @@ $ scss-to-css [input_path] [output_path]
|
|
|
85
87
|
- `[input_path]`: Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory.
|
|
86
88
|
- `[output_path]`: Path to file or directory where CSS + source map files will be stored, relative to original file location (if not provided, `css/` is used).
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
**๐ Note:** If folders are passed, files will be processed recursively unless `-R` or `--no-recursion` is passed.
|
|
89
91
|
|
|
90
92
|
#
|
|
91
93
|
|
|
@@ -127,7 +129,7 @@ Specify both **input and output** directories (outputs to `output_folder/`):
|
|
|
127
129
|
$ scss-to-css input_folder output_folder
|
|
128
130
|
```
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
**๐ Note:** Output CSS is minified unless `-M` or `--no-minify` is passed.
|
|
131
133
|
|
|
132
134
|
#
|
|
133
135
|
|
|
@@ -141,13 +143,17 @@ Boolean options:
|
|
|
141
143
|
-S, --no-source-maps Prevent source maps from being generated.
|
|
142
144
|
-M, --no-minify Disable minification of output CSS.
|
|
143
145
|
-R, --no-recursion Disable recursive file searching.
|
|
146
|
+
-c, --copy Copy compiled CSS to clipboard instead of
|
|
147
|
+
writing to file if single source file is
|
|
148
|
+
processed.
|
|
144
149
|
-q, --quiet Suppress all logging except errors.
|
|
145
150
|
|
|
146
151
|
Parameter options:
|
|
147
152
|
--ignore-files="file1.scss,file2.scss" Files to exclude from
|
|
148
153
|
compilation.
|
|
149
|
-
--comment="comment" Prepend comment to
|
|
150
|
-
Separate by
|
|
154
|
+
--comment="comment" Prepend header comment to
|
|
155
|
+
compiled CSS. Separate by
|
|
156
|
+
line using '\n'.
|
|
151
157
|
Info commands:
|
|
152
158
|
-h, --help Display help screen.
|
|
153
159
|
-v, --version Show version number.
|
|
@@ -179,7 +185,7 @@ const scssToCSS = require('@adamlui/scss-to-css');
|
|
|
179
185
|
|
|
180
186
|
### `compile(input[, options])`
|
|
181
187
|
|
|
182
|
-
Compiles SCSS based on the string input supplied.
|
|
188
|
+
๐ก Compiles SCSS based on the string input supplied.
|
|
183
189
|
|
|
184
190
|
If **source code** is passed, it is directly compiled, then an object containing `srcPath` + `code` + `srcMap` + `error` is returned:
|
|
185
191
|
|
|
@@ -213,21 +219,21 @@ scssToCSS.compile(inputDir, { minify: false });
|
|
|
213
219
|
|
|
214
220
|
Available parameters (and their default settings) are:
|
|
215
221
|
|
|
216
|
-
Name | Type | Desciption
|
|
217
|
-
|
|
218
|
-
`recursive` | Boolean | Recursively search for nested files if dir path passed.
|
|
219
|
-
`verbose` | Boolean | Show logging in console/terminal.
|
|
220
|
-
`dotFolders` | Boolean | Include dotfolders in file search.
|
|
221
|
-
`minify` | Boolean | Minify output CSS.
|
|
222
|
-
`sourceMaps` | Boolean | Generate CSS source maps.
|
|
223
|
-
`ignoreFiles` | Array | Files (by name) to exclude from compilation.
|
|
224
|
-
`comment` | String |
|
|
222
|
+
Name | Type | Desciption | Default value
|
|
223
|
+
--------------|---------|-------------------------------------------------------------------------|---------------
|
|
224
|
+
`recursive` | Boolean | Recursively search for nested files if dir path passed. | `true`
|
|
225
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
226
|
+
`dotFolders` | Boolean | Include dotfolders in file search. | `false`
|
|
227
|
+
`minify` | Boolean | Minify output CSS. | `true`
|
|
228
|
+
`sourceMaps` | Boolean | Generate CSS source maps. | `true`
|
|
229
|
+
`ignoreFiles` | Array | Files (by name) to exclude from compilation. | `[]`
|
|
230
|
+
`comment` | String | Header comment to prepend to compiled CSS. Separate by line using '\n'. | `''`
|
|
225
231
|
|
|
226
232
|
#
|
|
227
233
|
|
|
228
234
|
### `findSCSS(searchDir[, options])`
|
|
229
235
|
|
|
230
|
-
Searches for all SCSS files within the `searchDir` string passed (useful for discovering what files [`compile()`](#compileinput-options) will process) and returns an array containing their filepaths.
|
|
236
|
+
๐ก Searches for all SCSS files within the `searchDir` string passed (useful for discovering what files [`compile()`](#compileinput-options) will process) and returns an array containing their filepaths.
|
|
231
237
|
|
|
232
238
|
Options are boolean, passed as object properties. For example:
|
|
233
239
|
|
|
@@ -283,7 +289,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
283
289
|
<br>[Download](https://cdn.jsdelivr.net/gh/adamlui/js-utils/img-to-webp/img-to-webp.js) /
|
|
284
290
|
[Discuss](https://github.js-utils.com/discussions)
|
|
285
291
|
|
|
286
|
-
### [</> minify.js](https://minify-js.org)
|
|
292
|
+
### [</> minify.js](https://minify-js.org) <a href="https://github.com/toolleeo/cli-apps#programming"><img height=18 src="https://media.scsstocss.org/images/badges/awesome/badge.svg?52b67bc"></a>
|
|
287
293
|
|
|
288
294
|
> Recursively minify all JavaScript files.
|
|
289
295
|
<br>[Install](https://node.minify-js.org/#-installation) /
|
package/dist/cli.min.js
CHANGED
|
@@ -4,25 +4,27 @@
|
|
|
4
4
|
* Source: https://code.scsstocss.org/node.js
|
|
5
5
|
* Documentation: https://docs.scsstocss.org/node.js
|
|
6
6
|
*/
|
|
7
|
-
const pkgName="@adamlui/scss-to-css",copyright="ยฉ 2024 Adam Lui & contributors under the MIT license.",cmdFormat="scss-to-css [inputPath] [outputPath] [options]",srcURL="https://code.scsstocss.org/node.js",docURL="https://docs.scsstocss.org/node.js/#-command-line-usage",scssToCSS=require(__dirname.match(/src/)?"./scss-to-css":"./scss-to-css.min"),fs=require("fs"),path=require("path"),execSync=require("child_process")["execSync"],nc="[0m",br="[1;91m",by="[1;33m",bg="[1;92m",bw="[1;97m",config={},reArgs={flags:{dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,noSourceMaps:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMinify:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},paramOptions:{ignoreFiles:/^--?(?:ignore|skip|exclude)(?:d?-?files?)?(?:=.*|$)/,comment:/^--?comments?(?:=.*|$)/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(s=>{var e,o,n;s.startsWith("-")&&(n=Object.keys(reArgs.flags).find(e=>reArgs.flags[e].test(s)),e=Object.keys(reArgs.paramOptions).find(e=>reArgs.paramOptions[e].test(s)),o=Object.keys(reArgs.infoCmds).find(e=>reArgs.infoCmds[e].test(s)),n?config[n]=!0:e?(/=.+/.test(s)||(console.error(`
|
|
7
|
+
const pkgName="@adamlui/scss-to-css",copyright="ยฉ 2024 Adam Lui & contributors under the MIT license.",cmdFormat="scss-to-css [inputPath] [outputPath] [options]",srcURL="https://code.scsstocss.org/node.js",docURL="https://docs.scsstocss.org/node.js/#-command-line-usage",scssToCSS=require(__dirname.match(/src/)?"./scss-to-css":"./scss-to-css.min"),fs=require("fs"),path=require("path"),ncp=require("node-clipboardy"),execSync=require("child_process")["execSync"],nc="[0m",br="[1;91m",by="[1;33m",bg="[1;92m",bw="[1;97m",config={},reArgs={flags:{dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,noSourceMaps:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMinify:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/,copy:/^--?c(?:opy)?$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},paramOptions:{ignoreFiles:/^--?(?:ignore|skip|exclude)(?:d?-?files?)?(?:=.*|$)/,comment:/^--?comments?(?:=.*|$)/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(s=>{var e,o,n;s.startsWith("-")&&(n=Object.keys(reArgs.flags).find(e=>reArgs.flags[e].test(s)),e=Object.keys(reArgs.paramOptions).find(e=>reArgs.paramOptions[e].test(s)),o=Object.keys(reArgs.infoCmds).find(e=>reArgs.infoCmds[e].test(s)),n?config[n]=!0:e?(/=.+/.test(s)||(console.error(`
|
|
8
8
|
${br}ERROR: Arg [--${s.replace(/-/g,"")}] requires '=' followed by a value.`+nc),printHelpCmdAndDocURL(),process.exit(1)),n=s.split("=")[1],config[e]=parseInt(n)||n):o||(console.error(`
|
|
9
9
|
${br}ERROR: Arg [${s}] not recognized.`+nc),console.info(`
|
|
10
10
|
${by}Valid arguments are below.`+nc),printHelpSections(["flags","paramOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>reArgs.infoCmds.help.test(e)))printHelpSections();else if(process.argv.some(e=>reArgs.infoCmds.version.test(e))){const k=execSync(`npm view ${pkgName} version`).toString().trim()||"none";let e,s=process.cwd();for(;"/"!=s;){const n=path.join(s,"package.json");if(fs.existsSync(n)){const o=require(n);e=(o.dependencies?.[pkgName]||o.devDependencies?.[pkgName])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}s=path.dirname(s)}console.info(`
|
|
11
|
-
Global version: `+k),console.info("Local version: "+e)}else{const[p="",q=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,""))
|
|
11
|
+
Global version: `+k),console.info("Local version: "+e)}else{const[p="",q=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,""));let e=path.resolve(process.cwd(),p);if(p&&!fs.existsSync(e)){const v=e+".scss";fs.existsSync(v)?e=v:(console.error(`
|
|
12
12
|
${br}Error: First argument can only be an existing file or directory.`+`
|
|
13
|
-
'${
|
|
14
|
-
|
|
13
|
+
'${e}' does not exist.`+nc),console.info(`
|
|
15
14
|
${bg}Example valid command:
|
|
16
|
-
ยป scss-to-css . output.min.css`+nc),printHelpCmdAndDocURL(),process.exit(1))
|
|
15
|
+
ยป scss-to-css . output.min.css`+nc),printHelpCmdAndDocURL(),process.exit(1))}const s=e.endsWith(".scss")&&!fs.statSync(e).isDirectory()?[e]:scssToCSS.findSCSS(e,{recursive:!config.noRecursion,verbose:!config.quietMode,ignoreFiles:(config.ignoreFiles?.split(",")??[]).map(e=>e.trim())});if(config.dryRun)0<s.length?(console.info(`
|
|
17
16
|
${by}SCSS files to be compiled:`+nc),s.forEach(e=>console.info(e))):console.info(by+`
|
|
18
|
-
No SCSS files will be compiled.`+nc);else{const
|
|
19
|
-
${bg}Compilation complete!`+nc),printIfNotQuiet(bw+
|
|
20
|
-
|
|
17
|
+
No SCSS files will be compiled.`+nc);else{const y=[],z=s.map(e=>{var s=scssToCSS.compile(e,{verbose:!config.quietMode,minify:!config.noMinify,sourceMaps:!config.noSourceMaps,comment:config.comment?.replace(/\\n/g,"\n")});return s.error&&y.push(e),s}).filter(e=>!e.error);if(0<z?.length){const D=1<z.length?"s":"";printIfNotQuiet(`
|
|
18
|
+
${bg}Compilation complete!`+nc),printIfNotQuiet(bw+z.length+" CSS file"+D+(config.noSourceMaps?"":` + ${z.length} source map`+D)+" generated."+nc)}else printIfNotQuiet(`
|
|
19
|
+
${by}No SCSS files processed.`+nc);0<y.length&&(printIfNotQuiet(`
|
|
20
|
+
`+br+y.length+" file"+(1<y.length?"s":"")+" failed to compile:"+nc),y.forEach(e=>printIfNotQuiet(e))),0==z?.length&&process.exit(0),1==z?.length?(console.log(`
|
|
21
|
+
`+(bw+z[0].code+nc)),config.copy&&(printIfNotQuiet("\nCopying to clipboard..."),ncp.writeSync(z[0].code))):(printIfNotQuiet(`
|
|
22
|
+
Writing to file${1<z?.length?"s":""}...`),z?.forEach(({code:e,srcMap:s,srcPath:o})=>{var n=path.join(path.dirname(o),/(?:src|s[ac]ss)$/.test(path.dirname(o))?"../"+(q||"css"):q.endsWith(".css")?path.dirname(q):q||"css"),o=(q.endsWith(".css")&&p.endsWith(".scss")?path.basename(q).replace(/(\.min)?\.css$/,""):path.basename(o,".scss"))+".min.css",o=path.join(n,o);fs.existsSync(n)||fs.mkdirSync(n,{recursive:!0}),fs.writeFileSync(o,e,"utf8"),config.noSourceMaps||fs.writeFileSync(o+".map",JSON.stringify(s),"utf8")}))}}function printHelpSections(e=["header","usage","pathArgs","flags","paramOptions","infoCmds"]){var s=`[106m[30m ${pkgName.replace(/^@[^/]+\//,"")} ${nc} `;const o={header:[`
|
|
21
23
|
โ `+s+copyright,s+"Source: "+srcURL],usage:[`
|
|
22
24
|
${bw}o Usage:`+nc,` ${bw}ยป `+(bg+cmdFormat+nc)],pathArgs:[`
|
|
23
25
|
${bw}o Path arguments:`+nc," [inputPath] Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory."," [outputPath] Path to file or directory where CSS + sourcemap files will be stored, relative to original file location (if not provided, css/ is used)."],flags:[`
|
|
24
|
-
${bw}o Boolean options:`+nc," -n, --dry-run Don't actually compile the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -S, --no-source-maps Prevent source maps from being generated."," -M, --no-minify Disable minification of output CSS."," -R, --no-recursion Disable recursive file searching."," -q, --quiet Suppress all logging except errors."],paramOptions:[`
|
|
25
|
-
${bw}o Parameter options:`+nc,'--ignore-files="file1.scss,file2.scss" Files to exclude from compilation.',"--comment=\"comment\" Prepend comment to compiled CSS. Separate by line using '\\n'."],infoCmds:[`
|
|
26
|
+
${bw}o Boolean options:`+nc," -n, --dry-run Don't actually compile the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -S, --no-source-maps Prevent source maps from being generated."," -M, --no-minify Disable minification of output CSS."," -R, --no-recursion Disable recursive file searching."," -c, --copy Copy compiled CSS to clipboard instead of writing to file if single source file is processed."," -q, --quiet Suppress all logging except errors."],paramOptions:[`
|
|
27
|
+
${bw}o Parameter options:`+nc,'--ignore-files="file1.scss,file2.scss" Files to exclude from compilation.',"--comment=\"comment\" Prepend header comment to compiled CSS. Separate by line using '\\n'."],infoCmds:[`
|
|
26
28
|
${bw}o Info commands:`+nc," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(t=>{o[t]?.forEach(e=>{{var n=/header|usage/.test(t)?1:41;const i=process.stdout.columns||80,r=[],s=e.match(/\S+|\s+/g);let o="";s.forEach(e=>{var s=i-(0==r.length?0:n);o.length+"| ".length+e.length>s&&(r.push(0==r.length?o:o.trimStart()),o=""),o+=e}),r.push(0==r.length?o:o.trimStart()),r.forEach((e,s)=>console.info("| "+(0==s?e:" ".repeat(n)+e)))}})}),console.info("\nFor more help, please visit: "+bw+docURL+nc)}function printHelpCmdAndDocURL(){console.info(`
|
|
27
29
|
For more help, type 'scss-to-css --help' or visit
|
|
28
30
|
`+(bw+docURL+nc))}function printIfNotQuiet(e){config.quietMode||console.info(e)}
|
package/dist/scss-to-css.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Source: https://code.scsstocss.org/node.js
|
|
5
5
|
* Documentation: https://docs.scsstocss.org/node.js
|
|
6
6
|
*/
|
|
7
|
-
const fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(o,r={}){var e="https://docs.scsstocss.org/node.js/#findscsssearchdir-options",s={recursive:!0,verbose:!0,dotFolders:!1,ignoreFiles:[]};if("string"!=typeof o)console.error("findSCSS() ยป ERROR: 1st arg <searchDir> must be a string."),console.info("findSCSS() ยป For more help, please visit "+e);else{var i=path.resolve(process.cwd(),o);if(fs.existsSync(i)){if(validateOptions(r,s,e,"findSCSS('assets/scss', { verbose: false, dotFolders: true })")){r={...s,...r};const n=fs.readdirSync(o),c=[];return r.verbose&&!r.isRecursing&&console.info("findSCSS() ยป Searching for SCSS files..."),n.forEach(e=>{var s=path.resolve(o,e);fs.statSync(s).isDirectory()&&"node_modules"!=e&&r.recursive&&(r.dotFolders||!e.startsWith("."))?c.push(...findSCSS(s,{...r,isRecursing:!0})):e.endsWith(".scss")&&!r.ignoreFiles.includes(e)?c.push(s):r.verbose&&r.ignoreFiles.includes(e)&&console.info(`findSCSS() ยป ** ${e} ignored due to [options.ignoreFiles]`)}),!r.isRecursing&&r.verbose&&(console.info("findSCSS() ยป Search complete! "+(0==c.length?"No":c.length)+` file${
|
|
7
|
+
const fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(o,r={}){var e="https://docs.scsstocss.org/node.js/#findscsssearchdir-options",s={recursive:!0,verbose:!0,dotFolders:!1,ignoreFiles:[]};if("string"!=typeof o)console.error("findSCSS() ยป ERROR: 1st arg <searchDir> must be a string."),console.info("findSCSS() ยป For more help, please visit "+e);else{var i=path.resolve(process.cwd(),o);if(fs.existsSync(i)){if(validateOptions(r,s,e,"findSCSS('assets/scss', { verbose: false, dotFolders: true })")){r={...s,...r};const n=fs.readdirSync(o),c=[];return r.verbose&&!r.isRecursing&&console.info("findSCSS() ยป Searching for SCSS files..."),n.forEach(e=>{var s=path.resolve(o,e);fs.statSync(s).isDirectory()&&"node_modules"!=e&&r.recursive&&(r.dotFolders||!e.startsWith("."))?c.push(...findSCSS(s,{...r,isRecursing:!0})):e.endsWith(".scss")&&!r.ignoreFiles.includes(e)?c.push(s):r.verbose&&r.ignoreFiles.includes(e)&&console.info(`findSCSS() ยป ** ${e} ignored due to [options.ignoreFiles]`)}),!r.isRecursing&&r.verbose&&(console.info("findSCSS() ยป Search complete! "+(0==c.length?"No":c.length)+` file${1==c.length?"":"s"} found.`),"compile"==findSCSS.caller.name||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("findSCSS() ยป Check returned array.")),r.isRecursing||0<c.length?c:[]}}else console.error("findSCSS() ยป ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findSCSS() ยป ${i} does not exist.`),console.info("findSCSS() ยป For more help, please visit "+e)}}function compile(e,o={}){var s="https://docs.scsstocss.org/node.js/#compileinput-options",r={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0,ignoreFiles:[],comment:""};if("string"!=typeof e)console.error("compile() ยป ERROR: 1st arg <input> must be a string."),console.info("compile() ยป For more help, please visit "+s);else if(validateOptions(o,r,s,"compile('assets/scss', { recursive: false, minify: false })")){const t={style:(o={...r,...o}).minify?"compressed":"expanded",sourceMap:o.sourceMaps};if(fs.existsSync(e)){if(!e.endsWith(".scss"))return s=findSCSS(e,{recursive:o.recursive,verbose:o.verbose,dotFolders:o.dotFolders,ignoreFiles:o.ignoreFiles})?.map(e=>{o.verbose&&console.info(`compile() ยป ** Compiling ${e}...`);try{var s=sass.compile(e,t);return o.comment&&(s.css=c(s.css,o.comment)),{code:s.css,srcMap:s.sourceMap,srcPath:e,error:void 0}}catch(e){return console.error(`
|
|
8
8
|
compile() ยป ERROR: ${e.message}
|
|
9
9
|
`),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}).filter(e=>!e.error),o.verbose&&(0<s.length?console.info("compile() ยป Compilation complete! Check returned object."):console.info("compile() ยป No SCSS files processed.")),s;o.verbose&&console.info(`compile() ยป ** Compiling ${e}...`);try{var i=sass.compile(e,t);return o.comment&&(i.css=c(i.css,o.comment)),o.verbose&&!/cli(?:\.min)?\.js$/.test(require.main.filename)&&console.info("compile() ยป Compilation complete! Check returned object."),{code:i.css,srcMap:i.sourceMap,srcPath:path.resolve(process.cwd(),e),error:void 0}}catch(e){return console.error(`
|
|
10
10
|
compile() ยป ERROR: ${e.message}
|
package/docs/README.md
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
31
31
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
32
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.
|
|
32
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.10.1"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.10.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
33
33
|
<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>
|
|
34
34
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:node.js/src/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_scss-to-css%3Anode.js%2Fsrc%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>
|
|
35
35
|
<a href="https://github.com/toolleeo/cli-apps#conversion"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
@@ -58,6 +58,8 @@ $ npm install @adamlui/scss-to-css
|
|
|
58
58
|
|
|
59
59
|
<br>
|
|
60
60
|
|
|
61
|
+
<a href="https://github.com/sponsors/adamlui"><img src="https://media.scsstocss.org/images/banners/sponsor/$10/banner1660x260.png?2cba0ae"></a>
|
|
62
|
+
|
|
61
63
|
<img height=6px width="100%" src="https://media.scsstocss.org/images/separators/gradient-aqua.png?52b67bc">
|
|
62
64
|
|
|
63
65
|
## ๐ป Command line usage
|
|
@@ -72,7 +74,7 @@ Sample output:
|
|
|
72
74
|
|
|
73
75
|
<img src="https://cdn.jsdelivr.net/gh/adamlui/scss-to-css@b74edea/node.js/media/images/screenshots/cli/scss-to-css-docs-cmd-output.png">
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
**๐ Note:** Source maps are also generated by default unless `-S` or `--no-source-maps` is passed.
|
|
76
78
|
|
|
77
79
|
#
|
|
78
80
|
|
|
@@ -85,7 +87,7 @@ $ scss-to-css [input_path] [output_path]
|
|
|
85
87
|
- `[input_path]`: Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory.
|
|
86
88
|
- `[output_path]`: Path to file or directory where CSS + source map files will be stored, relative to original file location (if not provided, `css/` is used).
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
**๐ Note:** If folders are passed, files will be processed recursively unless `-R` or `--no-recursion` is passed.
|
|
89
91
|
|
|
90
92
|
#
|
|
91
93
|
|
|
@@ -127,7 +129,7 @@ Specify both **input and output** directories (outputs to `output_folder/`):
|
|
|
127
129
|
$ scss-to-css input_folder output_folder
|
|
128
130
|
```
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
**๐ Note:** Output CSS is minified unless `-M` or `--no-minify` is passed.
|
|
131
133
|
|
|
132
134
|
#
|
|
133
135
|
|
|
@@ -141,13 +143,17 @@ Boolean options:
|
|
|
141
143
|
-S, --no-source-maps Prevent source maps from being generated.
|
|
142
144
|
-M, --no-minify Disable minification of output CSS.
|
|
143
145
|
-R, --no-recursion Disable recursive file searching.
|
|
146
|
+
-c, --copy Copy compiled CSS to clipboard instead of
|
|
147
|
+
writing to file if single source file is
|
|
148
|
+
processed.
|
|
144
149
|
-q, --quiet Suppress all logging except errors.
|
|
145
150
|
|
|
146
151
|
Parameter options:
|
|
147
152
|
--ignore-files="file1.scss,file2.scss" Files to exclude from
|
|
148
153
|
compilation.
|
|
149
|
-
--comment="comment" Prepend comment to
|
|
150
|
-
Separate by
|
|
154
|
+
--comment="comment" Prepend header comment to
|
|
155
|
+
compiled CSS. Separate by
|
|
156
|
+
line using '\n'.
|
|
151
157
|
Info commands:
|
|
152
158
|
-h, --help Display help screen.
|
|
153
159
|
-v, --version Show version number.
|
|
@@ -179,7 +185,7 @@ const scssToCSS = require('@adamlui/scss-to-css');
|
|
|
179
185
|
|
|
180
186
|
### `compile(input[, options])`
|
|
181
187
|
|
|
182
|
-
Compiles SCSS based on the string input supplied.
|
|
188
|
+
๐ก Compiles SCSS based on the string input supplied.
|
|
183
189
|
|
|
184
190
|
If **source code** is passed, it is directly compiled, then an object containing `srcPath` + `code` + `srcMap` + `error` is returned:
|
|
185
191
|
|
|
@@ -213,21 +219,21 @@ scssToCSS.compile(inputDir, { minify: false });
|
|
|
213
219
|
|
|
214
220
|
Available parameters (and their default settings) are:
|
|
215
221
|
|
|
216
|
-
Name | Type | Desciption
|
|
217
|
-
|
|
218
|
-
`recursive` | Boolean | Recursively search for nested files if dir path passed.
|
|
219
|
-
`verbose` | Boolean | Show logging in console/terminal.
|
|
220
|
-
`dotFolders` | Boolean | Include dotfolders in file search.
|
|
221
|
-
`minify` | Boolean | Minify output CSS.
|
|
222
|
-
`sourceMaps` | Boolean | Generate CSS source maps.
|
|
223
|
-
`ignoreFiles` | Array | Files (by name) to exclude from compilation.
|
|
224
|
-
`comment` | String |
|
|
222
|
+
Name | Type | Desciption | Default value
|
|
223
|
+
--------------|---------|-------------------------------------------------------------------------|---------------
|
|
224
|
+
`recursive` | Boolean | Recursively search for nested files if dir path passed. | `true`
|
|
225
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
226
|
+
`dotFolders` | Boolean | Include dotfolders in file search. | `false`
|
|
227
|
+
`minify` | Boolean | Minify output CSS. | `true`
|
|
228
|
+
`sourceMaps` | Boolean | Generate CSS source maps. | `true`
|
|
229
|
+
`ignoreFiles` | Array | Files (by name) to exclude from compilation. | `[]`
|
|
230
|
+
`comment` | String | Header comment to prepend to compiled CSS. Separate by line using '\n'. | `''`
|
|
225
231
|
|
|
226
232
|
#
|
|
227
233
|
|
|
228
234
|
### `findSCSS(searchDir[, options])`
|
|
229
235
|
|
|
230
|
-
Searches for all SCSS files within the `searchDir` string passed (useful for discovering what files [`compile()`](#compileinput-options) will process) and returns an array containing their filepaths.
|
|
236
|
+
๐ก Searches for all SCSS files within the `searchDir` string passed (useful for discovering what files [`compile()`](#compileinput-options) will process) and returns an array containing their filepaths.
|
|
231
237
|
|
|
232
238
|
Options are boolean, passed as object properties. For example:
|
|
233
239
|
|
|
@@ -283,7 +289,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
283
289
|
<br>[Download](https://cdn.jsdelivr.net/gh/adamlui/js-utils/img-to-webp/img-to-webp.js) /
|
|
284
290
|
[Discuss](https://github.js-utils.com/discussions)
|
|
285
291
|
|
|
286
|
-
### [</> minify.js](https://minify-js.org)
|
|
292
|
+
### [</> minify.js](https://minify-js.org) <a href="https://github.com/toolleeo/cli-apps#programming"><img height=18 src="https://media.scsstocss.org/images/badges/awesome/badge.svg?52b67bc"></a>
|
|
287
293
|
|
|
288
294
|
> Recursively minify all JavaScript files.
|
|
289
295
|
<br>[Install](https://node.minify-js.org/#-installation) /
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamlui/scss-to-css",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Recursively compile all SCSS files into minified CSS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"main": "dist/scss-to-css.min.js",
|
|
13
13
|
"files": [
|
|
14
|
-
"dist",
|
|
15
14
|
"docs/",
|
|
16
15
|
"!docs/*/"
|
|
17
16
|
],
|
|
@@ -55,9 +54,10 @@
|
|
|
55
54
|
"url": "https://github.com/sponsors/adamlui"
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"
|
|
57
|
+
"node-clipboardy": "^1.0.3",
|
|
58
|
+
"sass": "^1.77.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@adamlui/minify.js": "^1.
|
|
61
|
+
"@adamlui/minify.js": "^1.7.0"
|
|
62
62
|
}
|
|
63
63
|
}
|