@adamlui/scss-to-css 1.7.9 → 1.7.11

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 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.7.9"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.9-44cc11.svg?logo=icinga&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.11"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.11-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_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
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>
@@ -275,7 +275,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
275
275
  ### [</> minify.js](https://minify-js.org)
276
276
 
277
277
  > Recursively minify all JavaScript files.
278
- <br>[Install](https://github.com/adamlui/js-utils/tree/main/minify.js#-installation) /
278
+ <br>[Install](https://docs.minify-js.org/#-installation) /
279
279
  [Readme](http://minify-js.org/#readme) /
280
280
  [CLI usage](http://minify-js.org/README.md#-command-line-usage) /
281
281
  [API usage](http://minify-js.org/README.md#-api-usage) /
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="",t="",c="",e="",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(`
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="",t="",c="",s="",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),d(["configOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>a.help.test(e)))d();else if(process.argv.some(e=>a.version.test(e)))console.info("v"+require("./package.json").version);else{const[f="",u=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),p=n.resolve(process.cwd(),f),m=(f&&!r.existsSync(p)&&(console.error(`
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
- '${p}' does not exist.`+i+`
6
+ '${h}' does not exist.`+i+`
7
7
 
8
- ${e}Example valid command:
9
- » scss-to-css . output.min.css`+i+`
10
-
11
- ${c}For all command options:
12
- » scss-to-css --help`+i),process.exit(1)),f.endsWith(".scss")?[p]:o.findSCSS(p,{recursive:!l.noRecursion,verbose:!l.quietMode}));if(l.dryRun)0<m.length?(console.info(`
13
- ${c}SCSS files to be compiled:`+i),m.forEach(e=>console.info(e))):console.info(c+`
14
- No SCSS files will be compiled.`+i);else{const h=[],g=m.map(e=>{var s=o.compile(e,{minify:!l.noMinify,sourceMaps:!l.noSourceMaps,verbose:!l.quietMode});return s.error&&h.push(e),s}).filter(e=>!e.error);if(g?.forEach(({code:e,srcMap:s,srcPath:o})=>{var i=n.join(n.dirname(o),/(?:src|s[ac]ss)$/.test(n.dirname(o))?"../"+(u||"css"):u.endsWith(".css")?n.dirname(u):u||"css"),o=(u.endsWith(".css")&&f.endsWith(".scss")?n.basename(u).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<g?.length){const S=1<g.length?"s":"";s(`
15
- ${e}Compilation complete!`+i),s(g.length+" CSS file"+S+(l.noSourceMaps?"":` + ${g.length} source map`+S)+" generated.")}else s(c+"No SCSS files processed."+i);0<h.length&&(s(`
16
- `+t+h.length+" file"+(1<h.length?"s":"")+" failed to compile:"+i),h.forEach(e=>s(e)))}}function d(e=["cmdFormat","pathArgs","configOptions","infoCmds"]){const s={cmdFormat:[`
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)}
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- const c=require("fs"),t=require("path"),n=require("sass");function l(o,s={}){var e={recursive:!0,verbose:!0,dotFolders:!1};if("string"!=typeof o)return console.error("findSCSS() » ERROR: 1st arg <searchDir> must be a string.");var r=t.resolve(process.cwd(),o);if(c.existsSync(r)){if(f(s,e,"findSCSS('assets/scss', { verbose: false, dotFolders: true })")){s={...e,...s};const i=c.readdirSync(o),n=[];return s.verbose&&!s.isRecursing&&console.info("findSCSS() » Searching for SCSS files..."),i.forEach(e=>{var r=t.resolve(o,e);c.statSync(r).isDirectory()&&"node_modules"!=e&&(s.dotFolders||!e.startsWith("."))&&s.recursive?n.push(...l(r,{...s,isRecursing:!0})):e.endsWith(".scss")&&n.push(r)}),!s.isRecursing&&s.verbose&&(console.info("findSCSS() » Search complete! "+(0===n.length?"No":n.length)+` file${0==n.length||1<n.length?"s":""} found.`),"compile"===l.caller.name||require.main.filename.endsWith("cli.js")||console.info("findSCSS() » Check returned array.")),s.isRecursing||0<n.length?n:[]}}else console.error("findSCSS() » ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findSCSS() » ${r} does not exist.`)}function e(e,o={}){var r={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0};if("string"!=typeof e)return console.error("compile() » ERROR: 1st arg <inputPath> must be a string.");if(e=t.resolve(process.cwd(),e),c.existsSync(e)){if(f(o,r,"compile('assets/scss', { recursive: false, minify: false })")){const i={style:(o={...r,...o}).minify?"compressed":"expanded",sourceMap:o.sourceMaps};if(c.existsSync(e)){if(!e.endsWith(".scss"))return r=l(e,{recursive:o.recursive,verbose:o.verbose,dotFolders:o.dotFolders})?.map(e=>{o.verbose&&console.info(`compile() » Compiling ${e}...`);try{var r=n.compile(e,i);return{code:r.css,srcMap:r.sourceMap,srcPath:e}}catch(e){return console.error(`
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||/cli(?:\.min)?\.js$/.test(require.main.filename)||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(`
3
3
  compile() » ERROR: ${e.message}
4
- `),{error:e}}}).filter(e=>!e.error),o.verbose&&(0<r.length?console.info("compile() » Compilation complete. Check returned object."):console.info("compile() » No SCSS files processed.")),r;o.verbose&&console.info(`compile() » Compiling ${e}...`);try{var s=n.compile(e,i);return o.verbose&&!require.main.filename.endsWith("cli.js")&&console.info("compile() » Compilation complete. Check returned object."),{code:s.css,srcMap:s.sourceMap,srcPath:t.resolve(process.cwd(),e)}}catch(e){return console.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&&!/cli(?:\.min)?\.js$/.test(require.main.filename)&&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(`
5
5
  compile() » ERROR: ${e.message}
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.`)}function f(e,r,o){const s=(f.caller?.name||"validateOptions")+"() » ",i=JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),n=Object.keys(r).join(", "),c=Object.keys(r).filter(e=>"boolean"==typeof r[e]),t=Object.keys(r).filter(e=>Number.isInteger(r[e]));var l=()=>{console.info(s+`Valid options: [ ${n} ]`),console.info(s+"If omitted, default settings are: "+i)};if("object"!=typeof e)return console.error(s+"ERROR: [options] can only be an object of key/values."),console.info(s+"Example valid call: "+o),l(),!1;for(const a in e){if("isRecursing"!=a&&!Object.prototype.hasOwnProperty.call(r,a))return console.error(s+`ERROR: \`${a}\` is an invalid option.`),l(),!1;if(c.includes(a)&&"boolean"!=typeof e[a])return console.error(s+`ERROR: [${a}] option can only be \`true\` or \`false\`.`),!1;if(t.includes(a)&&(e[a]=parseInt(e[a],10),isNaN(e[a])||e[a]<1))return console.error(s+`ERROR: [${a}] option can only be an integer > 0.`),!1}return!0}module.exports={compile:e,find:l,findSCSS:l};
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/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
+ &nbsp;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.11"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.11-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/scss-to-css",
3
- "version": "1.7.9",
3
+ "version": "1.7.11",
4
4
  "description": "Recursively compile all SCSS files into minified CSS",
5
5
  "author": {
6
6
  "name": "Adam Lui",
@@ -20,7 +20,7 @@
20
20
  "scss-to-css": "dist/cli.min.js"
21
21
  },
22
22
  "directories": {
23
- "lib": ".",
23
+ "lib": "./dist",
24
24
  "doc": "./docs"
25
25
  },
26
26
  "scripts": {
@@ -51,13 +51,13 @@
51
51
  "url": "https://js-utils.com/issues"
52
52
  },
53
53
  "dependencies": {
54
- "sass": "^1.74.1"
54
+ "sass": "^1.75.0"
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.4.10"
61
+ "@adamlui/minify.js": "^1.5.1"
62
62
  }
63
63
  }