@adamlui/scss-to-css 1.7.8 → 1.7.10
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 +13 -10
- package/dist/cli.min.js +12 -13
- package/dist/scss-to-css.min.js +4 -3
- package/docs/LICENSE.md +1 -0
- package/docs/README.md +290 -0
- package/docs/SECURITY.md +2 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
English |
|
|
9
9
|
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/zh-cn#readme">简体中文</a> |
|
|
10
10
|
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/zh-tw#readme">繁體中文</a> |
|
|
11
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/ja#readme">日本語</a> |
|
|
11
12
|
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/hi#readme">हिंदी</a> |
|
|
12
13
|
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/bn#readme">বাংলা</a> |
|
|
13
14
|
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/mr#readme">मराठी</a> |
|
|
@@ -28,10 +29,10 @@
|
|
|
28
29
|
|
|
29
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>
|
|
30
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>
|
|
31
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.7.
|
|
32
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.7.10"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.10-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
32
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>
|
|
33
34
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:scss-to-css/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_js-utils%3Ascss-to-css%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>
|
|
34
|
-
<a href="https://github.com/toolleeo/cli-apps#conversion"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-
|
|
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>
|
|
35
36
|
|
|
36
37
|
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
37
38
|
|
|
@@ -155,7 +156,7 @@ Info commands:
|
|
|
155
156
|
|
|
156
157
|
You can also import **scss-to-css** into your app to use its API methods, both as an ECMAScript module or a CommonJS module.
|
|
157
158
|
|
|
158
|
-
####
|
|
159
|
+
#### ECMAScript*:
|
|
159
160
|
|
|
160
161
|
```js
|
|
161
162
|
import * as scssToCSS from '@adamlui/scss-to-css';
|
|
@@ -269,19 +270,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
269
270
|
|
|
270
271
|
> Recursively compress all images to WEBPs.
|
|
271
272
|
<br>[Download](https://raw.githubusercontent.com/adamlui/js-utils/main/img-to-webp/img-to-webp.js) /
|
|
272
|
-
[Discuss](https://
|
|
273
|
+
[Discuss](https://js-utils.com/discussions)
|
|
273
274
|
|
|
274
|
-
### [</> minify.js](https://
|
|
275
|
+
### [</> minify.js](https://minify-js.org)
|
|
275
276
|
|
|
276
277
|
> Recursively minify all JavaScript files.
|
|
277
|
-
<br>[Install](https://
|
|
278
|
-
[Readme](
|
|
279
|
-
[
|
|
278
|
+
<br>[Install](https://docs.minify-js.org/#-installation) /
|
|
279
|
+
[Readme](http://minify-js.org/#readme) /
|
|
280
|
+
[CLI usage](http://minify-js.org/README.md#-command-line-usage) /
|
|
281
|
+
[API usage](http://minify-js.org/README.md#-api-usage) /
|
|
282
|
+
[Discuss](https://js-utils.com/discussions)
|
|
280
283
|
|
|
281
284
|
<br>
|
|
282
285
|
|
|
283
286
|
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
284
287
|
|
|
285
|
-
<
|
|
286
|
-
<a href="https://
|
|
288
|
+
<picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/white/icon32x27.png"><img height=13 src="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/dark-gray/icon32x27.png"></picture> <a href="https://js-utils.com">**More JavaScript utilities**</a> /
|
|
289
|
+
<a href="https://js-utils.com/discussions">Discuss</a> /
|
|
287
290
|
<a href="#--scss-to-css">Back to top ↑</a>
|
package/dist/cli.min.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const r=require("fs"),n=require("path"),o=require(__dirname.match(/src/)?"./scss-to-css":"./scss-to-css.min"),i="[0m",t="[1;91m",c="[1;33m",
|
|
2
|
+
const e="https://github.com/adamlui/js-utils/tree/main/scss-to-css#-command-line-usage",r=require("fs"),n=require("path"),o=require(__dirname.match(/src/)?"./scss-to-css":"./scss-to-css.min"),i="[0m",t="[1;91m",c="[1;33m",s="[1;92m",l={},a={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)?$/,help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/};if(process.argv.forEach(s=>{var e;s.startsWith("-")&&((e=Object.keys(a).find(e=>a[e].test(s)))?l[e]=!0:(console.error(`
|
|
3
3
|
${t}ERROR: Arg [${s}] not recognized.`+i),console.info(`
|
|
4
|
-
${c}Valid arguments are below.`+i),
|
|
4
|
+
${c}Valid arguments are below.`+i),u(["configOptions","infoCmds"]),d(),process.exit(1)))}),process.argv.some(e=>a.help.test(e)))u();else if(process.argv.some(e=>a.version.test(e)))console.info("v"+require("./package.json").version);else{const[p="",m=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),h=n.resolve(process.cwd(),p),g=(p&&!r.existsSync(h)&&(console.error(`
|
|
5
5
|
${t}Error: First argument can only be an existing file or directory.`+`
|
|
6
|
-
'${
|
|
6
|
+
'${h}' does not exist.`+i+`
|
|
7
7
|
|
|
8
|
-
${
|
|
9
|
-
» scss-to-css . output.min.css`+i
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
${
|
|
16
|
-
`+
|
|
17
|
-
${c}scss-to-css [inputPath] [outputPath] [options]`+i],pathArgs:["\nPath arguments:"," [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)."],configOptions:["\nConfig options:"," -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."],infoCmds:["\nInfo commands:"," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{s[e]?.forEach(e=>{{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:30);o.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(30)+e))}})})}function s(e){l.quietMode||console.info(e)}
|
|
8
|
+
${s}Example valid command:
|
|
9
|
+
» scss-to-css . output.min.css`+i),d(),process.exit(1)),p.endsWith(".scss")?[h]:o.findSCSS(h,{recursive:!l.noRecursion,verbose:!l.quietMode}));if(l.dryRun)0<g.length?(console.info(`
|
|
10
|
+
${c}SCSS files to be compiled:`+i),g.forEach(e=>console.info(e))):console.info(c+`
|
|
11
|
+
No SCSS files will be compiled.`+i);else{const S=[],v=g.map(e=>{var s=o.compile(e,{minify:!l.noMinify,sourceMaps:!l.noSourceMaps,verbose:!l.quietMode});return s.error&&S.push(e),s}).filter(e=>!e.error);if(v?.forEach(({code:e,srcMap:s,srcPath:o})=>{var i=n.join(n.dirname(o),/(?:src|s[ac]ss)$/.test(n.dirname(o))?"../"+(m||"css"):m.endsWith(".css")?n.dirname(m):m||"css"),o=(m.endsWith(".css")&&p.endsWith(".scss")?n.basename(m).replace(/(\.min)?\.css$/,""):n.basename(o,".scss"))+".min.css",o=n.join(i,o);r.existsSync(i)||r.mkdirSync(i,{recursive:!0}),r.writeFileSync(o,e,"utf8"),l.noSourceMaps||r.writeFileSync(o+".map",JSON.stringify(s),"utf8")}),0<v?.length){const y=1<v.length?"s":"";f(`
|
|
12
|
+
${s}Compilation complete!`+i),f(v.length+" CSS file"+y+(l.noSourceMaps?"":` + ${v.length} source map`+y)+" generated.")}else f(c+"No SCSS files processed."+i);0<S.length&&(f(`
|
|
13
|
+
`+t+S.length+" file"+(1<S.length?"s":"")+" failed to compile:"+i),S.forEach(e=>f(e)))}}function u(e=["cmdFormat","pathArgs","configOptions","infoCmds"]){const s={cmdFormat:[`
|
|
14
|
+
${c}scss-to-css [inputPath] [outputPath] [options]`+i],pathArgs:["\nPath arguments:"," [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)."],configOptions:["\nConfig options:"," -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."],infoCmds:["\nInfo commands:"," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{s[e]?.forEach(e=>{{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:30);o.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(30)+e))}})})}function d(){console.info(`
|
|
15
|
+
${c}For more help, type 'scss-to-css --help' or visit
|
|
16
|
+
`+(e+i))}function f(e){l.quietMode||console.info(e)}
|
package/dist/scss-to-css.min.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const c=require("fs"),l=require("path"),t=require("sass");function a(s,r={}){var e="https://github.com/adamlui/js-utils/tree/main/scss-to-css#findscsssearchdir-options",o={recursive:!0,verbose:!0,dotFolders:!1};if("string"!=typeof s)console.error("findSCSS() » ERROR: 1st arg <searchDir> must be a string."),console.info("findSCSS() » For more help, please visit "+e);else{var i=l.resolve(process.cwd(),s);if(c.existsSync(i)){if(u(r,o,e,"findSCSS('assets/scss', { verbose: false, dotFolders: true })")){r={...o,...r};const n=c.readdirSync(s),t=[];return r.verbose&&!r.isRecursing&&console.info("findSCSS() » Searching for SCSS files..."),n.forEach(e=>{var o=l.resolve(s,e);c.statSync(o).isDirectory()&&"node_modules"!=e&&(r.dotFolders||!e.startsWith("."))&&r.recursive?t.push(...a(o,{...r,isRecursing:!0})):e.endsWith(".scss")&&t.push(o)}),!r.isRecursing&&r.verbose&&(console.info("findSCSS() » Search complete! "+(0===t.length?"No":t.length)+` file${0==t.length||1<t.length?"s":""} found.`),"compile"===a.caller.name||require.main.filename.endsWith("cli.js")||console.info("findSCSS() » Check returned array.")),r.isRecursing||0<t.length?t:[]}}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 e(e,s={}){var o="https://github.com/adamlui/js-utils/tree/main/scss-to-css#compileinputpath-options",r={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0};if("string"!=typeof e)console.error("compile() » ERROR: 1st arg <inputPath> must be a string."),console.info("compile() » For more help, please visit "+o);else if(e=l.resolve(process.cwd(),e),c.existsSync(e)){if(u(s,r,o,"compile('assets/scss', { recursive: false, minify: false })")){const n={style:(s={...r,...s}).minify?"compressed":"expanded",sourceMap:s.sourceMaps};if(c.existsSync(e)){if(!e.endsWith(".scss"))return r=a(e,{recursive:s.recursive,verbose:s.verbose,dotFolders:s.dotFolders})?.map(e=>{s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var o=t.compile(e,n);return{code:o.css,srcMap:o.sourceMap,srcPath:e}}catch(e){return console.error(`
|
|
2
3
|
compile() » ERROR: ${e.message}
|
|
3
|
-
`),{error:e}}}).filter(e=>!e.error),
|
|
4
|
+
`),{error:e}}}).filter(e=>!e.error),s.verbose&&(0<r.length?console.info("compile() » Compilation complete. Check returned object."):console.info("compile() » No SCSS files processed.")),r;s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var i=t.compile(e,n);return s.verbose&&!require.main.filename.endsWith("cli.js")&&console.info("compile() » Compilation complete. Check returned object."),{code:i.css,srcMap:i.sourceMap,srcPath:l.resolve(process.cwd(),e)}}catch(e){return console.error(`
|
|
4
5
|
compile() » ERROR: ${e.message}
|
|
5
|
-
`),{error:e}}}}}else console.error("compile() » ERROR: 1st arg <inputPath> must be an existing directory or file."),console.error(`compile() » ${e} does not exist.`)}function
|
|
6
|
+
`),{error:e}}}}}else console.error("compile() » ERROR: 1st arg <inputPath> must be an existing directory or file."),console.error(`compile() » ${e} does not exist.`),console.info("compile() » For more help, please visit "+o)}function u(e,o,s,r){const i=JSON.stringify(o,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),n=Object.keys(o).join(", "),t=Object.keys(o).filter(e=>"boolean"==typeof o[e]),c=Object.keys(o).filter(e=>Number.isInteger(o[e])),l=(u.caller?.name||"validateOptions")+"() » ";var a=()=>{console.info(l+`Valid options: [ ${n} ]`),console.info(l+"If omitted, default settings are: "+i)},p=()=>{console.info(l+"For more help, please visit "+s)};if("object"!=typeof e)return console.error(l+"ERROR: [options] can only be an object of key/values."),console.info(l+"Example valid call: "+r),a(),p(),!1;for(const f in e){if("isRecursing"!=f&&!Object.prototype.hasOwnProperty.call(o,f))return console.error(l+`ERROR: \`${f}\` is an invalid option.`),a(),p(),!1;if(t.includes(f)&&"boolean"!=typeof e[f])return console.error(l+`ERROR: [${f}] option can only be \`true\` or \`false\`.`),p(),!1;if(c.includes(f)&&(e[f]=parseInt(e[f],10),isNaN(e[f])||e[f]<1))return console.error(l+`ERROR: [${f}] option can only be an integer > 0.`),p(),!1}return!0}module.exports={compile:e,find:a,findSCSS:a};
|
package/docs/LICENSE.md
CHANGED
package/docs/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
<table align="center">
|
|
2
|
+
<td align="center" width=1000>
|
|
3
|
+
<h6>
|
|
4
|
+
<picture>
|
|
5
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/white/icon32.svg">
|
|
6
|
+
<img height=14 src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/black/icon32.svg">
|
|
7
|
+
</picture>
|
|
8
|
+
English |
|
|
9
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/zh-cn#readme">简体中文</a> |
|
|
10
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/zh-tw#readme">繁體中文</a> |
|
|
11
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/ja#readme">日本語</a> |
|
|
12
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/hi#readme">हिंदी</a> |
|
|
13
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/bn#readme">বাংলা</a> |
|
|
14
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/mr#readme">मराठी</a> |
|
|
15
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/pa#readme">ਪੰਜਾਬੀ</a> |
|
|
16
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/de#readme">Deutsch</a> |
|
|
17
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/es#readme">Español</a> |
|
|
18
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/fr#readme">Français</a> |
|
|
19
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/it#readme">Italiano</a> |
|
|
20
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/nl#readme">Nederlands</a> |
|
|
21
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/pt#readme">Português</a>
|
|
22
|
+
</h6>
|
|
23
|
+
</td>
|
|
24
|
+
</table>
|
|
25
|
+
|
|
26
|
+
# { } scss-to-css
|
|
27
|
+
|
|
28
|
+
### Recursively compile all SCSS files into minified CSS.
|
|
29
|
+
|
|
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
|
+
<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.7.10"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.10-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
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
|
+
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:scss-to-css/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_js-utils%3Ascss-to-css%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
|
+
<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>
|
|
36
|
+
|
|
37
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
38
|
+
|
|
39
|
+
## ⚡ Installation
|
|
40
|
+
|
|
41
|
+
As a **global utility**:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
$ npm install -g @adamlui/scss-to-css
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
As a **dev dependency** (e.g. for build scripts), from your project root:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
$ npm install -D @adamlui/scss-to-css
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
As a **runtime dependency** (e.g. for on-the-fly compilation), from your project root:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
$ npm install @adamlui/scss-to-css
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
<br>
|
|
60
|
+
|
|
61
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
62
|
+
|
|
63
|
+
## 💻 Command line usage
|
|
64
|
+
|
|
65
|
+
The basic **global command** is:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
$ scss-to-css
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Sample output:
|
|
72
|
+
|
|
73
|
+
<img src="https://github.com/adamlui/js-utils/blob/main/scss-to-css/media/images/sample-output.png">
|
|
74
|
+
|
|
75
|
+
**💡 Note:** Source maps are also generated by default unless `-S` or `--no-source-maps` is passed.
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
|
|
79
|
+
To specify **input/output** paths:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
$ scss-to-css [input_path] [output_path]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- `[input_path]`: Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory.
|
|
86
|
+
- `[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
|
+
|
|
88
|
+
**💡 Note:** If folders are passed, files will be processed recursively unless `-R` or `--no-recursion` is passed.
|
|
89
|
+
|
|
90
|
+
#
|
|
91
|
+
|
|
92
|
+
To use as a **package script**, in your project's `package.json`:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
"scripts": {
|
|
96
|
+
"build:css": "<scss-to-css-cmd>"
|
|
97
|
+
},
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Replace `<scss-to-css-cmd>` with `scss-to-css` + optional args. Then, `npm run build:css` can be used to run the command.
|
|
101
|
+
|
|
102
|
+
#
|
|
103
|
+
|
|
104
|
+
### Example commands
|
|
105
|
+
|
|
106
|
+
Compile all SCSS files in the **current directory** (outputs to `css/`):
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
$ scss-to-css
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Compile all SCSS files in a **specific directory** (outputs to `path/to/your/directory/css/`):
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
$ scss-to-css path/to/your/directory
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Compile a **specific file** (outputs to `path/to/your/css/file.min.css`):
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
$ scss-to-css path/to/your/file.scss
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Specify both **input and output** directories (outputs to `output_folder/`):
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
$ scss-to-css input_folder output_folder
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**💡 Note:** Output CSS is minified unless `-M` or `--no-minify` is passed.
|
|
131
|
+
|
|
132
|
+
#
|
|
133
|
+
|
|
134
|
+
### Command line options
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Config options:
|
|
138
|
+
-n, --dry-run Don't actually compile the file(s), just
|
|
139
|
+
show if they will be processed.
|
|
140
|
+
-d, --include-dotfolders Include dotfolders in file search.
|
|
141
|
+
-S, --no-source-maps Prevent source maps from being generated.
|
|
142
|
+
-M, --no-minify Disable minification of output CSS.
|
|
143
|
+
-R, --no-recursion Disable recursive file searching.
|
|
144
|
+
-q, --quiet Suppress all logging except errors.
|
|
145
|
+
|
|
146
|
+
Info commands:
|
|
147
|
+
-h, --help Display help screen.
|
|
148
|
+
-v, --version Show version number.
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
<br>
|
|
152
|
+
|
|
153
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
154
|
+
|
|
155
|
+
## 🔌 API usage
|
|
156
|
+
|
|
157
|
+
You can also import **scss-to-css** into your app to use its API methods, both as an ECMAScript module or a CommonJS module.
|
|
158
|
+
|
|
159
|
+
#### ECMAScript*:
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
import * as scssToCSS from '@adamlui/scss-to-css';
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### CJS:
|
|
166
|
+
|
|
167
|
+
```js
|
|
168
|
+
const scssToCSS = require('@adamlui/scss-to-css');
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
###### _*Node.js version 14 or higher required_
|
|
172
|
+
|
|
173
|
+
#
|
|
174
|
+
|
|
175
|
+
### `compile(inputPath[, options])`
|
|
176
|
+
|
|
177
|
+
Compiles SCSS found in the `inputPath` provided into CSS data.
|
|
178
|
+
|
|
179
|
+
If a **file path** is passed, the file's code is compiled to CSS, then an object containing `srcPath` + `code` + `error` is returned:
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
const compileResult = scssToCSS.compile('assets/style.scss');
|
|
183
|
+
|
|
184
|
+
console.log(compileResult.error); // outputs runtime error, or `undefined` if no error
|
|
185
|
+
console.log(compileResult.code); // outputs compiled CSS from assets/style.scss
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
If a **directory path** is passed, SCSS files are searched for (recursively by default), each one's code is loaded then compiled, then an array of objects containing `srcPath` + `code` + `error` is returned:
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
// Outputs paths to SCSS files in working directory + all nested directories
|
|
192
|
+
const compileResults = scssToCSS.compile('.');
|
|
193
|
+
compileResults.forEach(result => console.log(result.srcPath));
|
|
194
|
+
|
|
195
|
+
// Outputs compiled CSS from 2nd SCSS file if found, or `undefined` if not found
|
|
196
|
+
console.log(compileResults[1].code);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Options are boolean, passed as object properties. For example:
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
// Returns array of data objects where `.code` contains unminified CSS
|
|
203
|
+
scssToCSS.compile(inputDir, { minify: false });
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Available parameters (and their default settings) are:
|
|
207
|
+
|
|
208
|
+
Name | Desciption | Default value
|
|
209
|
+
-------------|---------------------------------------------------------|---------------
|
|
210
|
+
`recursive` | Recursively search for nested files if dir path passed. | `true`
|
|
211
|
+
`verbose` | Show logging in console/terminal. | `true`
|
|
212
|
+
`dotFolders` | Include dotfolders in file search. | `false`
|
|
213
|
+
`minify` | Minify output CSS. | `true`
|
|
214
|
+
`sourceMaps` | Generate CSS source maps. | `true`
|
|
215
|
+
|
|
216
|
+
#
|
|
217
|
+
|
|
218
|
+
### `findSCSS(searchDir[, options])`
|
|
219
|
+
|
|
220
|
+
Searches for all SCSS files within the `searchDir` string passed (useful for discovering what files [`compile()`](#compileinputpath-options) will process) and returns an array containing their filepaths.
|
|
221
|
+
|
|
222
|
+
Options are boolean, passed as object properties. For example:
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
// Search for SCSS files in exactly assets/scss:
|
|
226
|
+
const searchResults = scssToCSS.findSCSS('assets/scss', { recursive: false });
|
|
227
|
+
console.log(searchResults);
|
|
228
|
+
|
|
229
|
+
/* sample output:
|
|
230
|
+
|
|
231
|
+
findSCSS() » Searching for SCSS files...
|
|
232
|
+
findSCSS() » Search complete! 2 files found.
|
|
233
|
+
findSCSS() » Check returned array.
|
|
234
|
+
[
|
|
235
|
+
'E:\\js\\utils\\scss-to-css\assets\\scss\\foo.scss',
|
|
236
|
+
'E:\\js\\utils\\scss-to-css\assets\\scss\\bar.scss'
|
|
237
|
+
]
|
|
238
|
+
*/
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Available parameters (and their default settings) are:
|
|
242
|
+
|
|
243
|
+
Name | Desciption | Default value
|
|
244
|
+
-------------|----------------------------------------------------------|---------------
|
|
245
|
+
`recursive` | Recursively search for nested files in searchDir passed. | `true`
|
|
246
|
+
`verbose` | Show logging in console/terminal. | `true`
|
|
247
|
+
`dotFolders` | Include dotfolders in file search. | `false`
|
|
248
|
+
|
|
249
|
+
<br>
|
|
250
|
+
|
|
251
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
252
|
+
|
|
253
|
+
## 🏛️ MIT License
|
|
254
|
+
|
|
255
|
+
**Copyright © 2024 [Adam Lui](https://github.com/adamlui) & contributors**
|
|
256
|
+
|
|
257
|
+
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:
|
|
258
|
+
|
|
259
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
260
|
+
|
|
261
|
+
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.
|
|
262
|
+
|
|
263
|
+
<br>
|
|
264
|
+
|
|
265
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
266
|
+
|
|
267
|
+
## 🛠️ Related utilities
|
|
268
|
+
|
|
269
|
+
### [🖼️ img-to-webp](https://github.com/adamlui/js-utils/tree/main/img-to-webp)
|
|
270
|
+
|
|
271
|
+
> Recursively compress all images to WEBPs.
|
|
272
|
+
<br>[Download](https://raw.githubusercontent.com/adamlui/js-utils/main/img-to-webp/img-to-webp.js) /
|
|
273
|
+
[Discuss](https://js-utils.com/discussions)
|
|
274
|
+
|
|
275
|
+
### [</> minify.js](https://minify-js.org)
|
|
276
|
+
|
|
277
|
+
> Recursively minify all JavaScript files.
|
|
278
|
+
<br>[Install](https://docs.minify-js.org/#-installation) /
|
|
279
|
+
[Readme](http://minify-js.org/#readme) /
|
|
280
|
+
[CLI usage](http://minify-js.org/README.md#-command-line-usage) /
|
|
281
|
+
[API usage](http://minify-js.org/README.md#-api-usage) /
|
|
282
|
+
[Discuss](https://js-utils.com/discussions)
|
|
283
|
+
|
|
284
|
+
<br>
|
|
285
|
+
|
|
286
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
287
|
+
|
|
288
|
+
<picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/white/icon32x27.png"><img height=13 src="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/dark-gray/icon32x27.png"></picture> <a href="https://js-utils.com">**More JavaScript utilities**</a> /
|
|
289
|
+
<a href="https://js-utils.com/discussions">Discuss</a> /
|
|
290
|
+
<a href="#--scss-to-css">Back to top ↑</a>
|
package/docs/SECURITY.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="zh-cn/SECURITY.md">简体中文</a> |
|
|
9
|
-
<a href="zh-tw/SECURITY.md">繁體中文</a> |
|
|
9
|
+
<a href="zh-tw/SECURITY.md">繁體中文</a> | |
|
|
10
|
+
<a href="ja/SECURITY.md">日本語</a> |
|
|
10
11
|
<a href="hi/SECURITY.md">हिंदी</a> |
|
|
11
12
|
<a href="bn/SECURITY.md">বাংলা</a> |
|
|
12
13
|
<a href="mr/SECURITY.md">मराठी</a> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamlui/scss-to-css",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.10",
|
|
4
4
|
"description": "Recursively compile all SCSS files into minified CSS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"url": "https://js-utils.com/issues"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"sass": "^1.
|
|
54
|
+
"sass": "^1.74.1"
|
|
55
55
|
},
|
|
56
56
|
"funding": {
|
|
57
57
|
"type": "github",
|
|
58
58
|
"url": "https://github.com/sponsors/adamlui"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@adamlui/minify.js": "^1.
|
|
61
|
+
"@adamlui/minify.js": "^1.5.0"
|
|
62
62
|
}
|
|
63
63
|
}
|