@adamlui/scss-to-css 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,8 +33,8 @@
33
33
  <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>
34
34
  <a href="#%EF%B8%8F-mit-license">
35
35
  <img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
36
- <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.0.1">
37
- <img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
36
+ <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.1.0">
37
+ <img height=31 src="https://img.shields.io/badge/Latest_Build-2.1.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
38
38
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code">
39
39
  <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>
40
40
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:src/scss-to-css.js">
@@ -163,11 +163,39 @@ Parameter options:
163
163
  --comment="comment" Prepend header comment to
164
164
  compiled CSS. Separate by
165
165
  line using '\n'.
166
- Info commands:
166
+ --config="path/to/file" Load custom config file.
167
+
168
+ Commands:
169
+ -i, --init Create config file (in project root).
167
170
  -h, --help Display help screen.
168
171
  -v, --version Show version number.
169
172
  ```
170
173
 
174
+ #
175
+
176
+ ### Configuration file
177
+
178
+ **scss-to-css** can be customized using a `scss-to-css.config.mjs` or `scss-to-css.config.js` placed in your project root.
179
+
180
+ Example defaults:
181
+
182
+ ```js
183
+ export default {
184
+ dryRun: false, // don't actually minify the file(s), just show if they will be processed
185
+ includeDotFolders: false, // include dotfolders in file search
186
+ noSourceMaps: false, // prevent source maps from being generated
187
+ noMinify: false, // disable minification of output CSS
188
+ noRecursion: false, // disable recursive file searching
189
+ relativeOutput: false, // output files relative to each src file instead of to input root
190
+ copy: false, // copy compiled CSS to clipboard instead of write to file if single file processed
191
+ quietMode: false, // suppress all logging except errors
192
+ ignores: '', // files/dirs to exclude from minification
193
+ comment: '' // header comment to prepend to minified code
194
+ }
195
+ ```
196
+
197
+ 💡 Run `scss-to-css init` to generate a template `scss-to-css.config.mjs` in your project root.
198
+
171
199
  <br>
172
200
 
173
201
  <img height=6px width="100%" src="https://assets.scsstocss.org/images/separators/aqua-gradient.png?v=7e4a141">
@@ -179,7 +207,7 @@ You can also import **scss-to-css** into your app to use its API methods, both a
179
207
  #### ECMAScript*:
180
208
 
181
209
  ```js
182
- import scssToCSS from '@adamlui/scss-to-css';
210
+ import scssToCSS from '@adamlui/scss-to-css'
183
211
  ```
184
212
 
185
213
  #### CJS:
@@ -1,21 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * © 2024 Adam Lui & contributors under the MIT license.
4
- * Source: https://github.com/adamlui/scss-to-css/tree/main/src
5
- * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
3
+ * © 2024–2026 Adam Lui & contributors under the MIT license.
4
+ * Source: https://github.com/adamlui/scss-to-css/tree/main/src
5
+ * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
6
6
  */
7
- (()=>{globalThis.env={devMode:__dirname.match(/[\\/]src/)};let i=require("node-clipboardy"),t=require("fs"),l=require("path"),f=require(`./lib/print${env.devMode?"":".min"}.js`),r=require(`../scss-to-css${env.devMode?"":".min"}.js`);if(Object.assign(globalThis.app??={},require(`../${env.devMode?"../":"./data/"}app.json`)),app.urls.docs+="/#-command-line-usage",app.colors={nc:"",br:"",by:"",bg:"",bw:"",blk:"",tlBG:""},app.regex={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))$/,relativeOutput:/^--?(?:r|relative-?output?=?(?:true|1)?)$/,copy:/^--?c(?:opy)?$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},paramOptions:{ignores:/^--?(?:ignores?|(?:ignore|skip|exclude)(?:d?-?files?)?)(?:=.*|$)/,comment:/^--?comments?(?:=.*|$)/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/},version:/^[~^>=]?\d+\.\d+\.\d+$/},app.config={},process.argv.forEach(o=>{var e,s,i;o.startsWith("-")&&(e=Object.keys(app.regex.paramOptions).find(e=>app.regex.paramOptions[e].test(o)),i=Object.keys(app.regex.flags).find(e=>app.regex.flags[e].test(o)),s=Object.keys(app.regex.infoCmds).find(e=>app.regex.infoCmds[e].test(o)),i?app.config[i]=!0:e?(/=.+/.test(o)||(console.error(`
8
- ${app.colors.br}ERROR: Arg [--${o.replace(/-/g,"")}] requires '=' followed by a value.`+app.colors.nc),f.helpCmdAndDocURL(),process.exit(1)),i=o.split("=")[1],app.config[e]=parseInt(i)||i):s||(console.error(`
9
- ${app.colors.br}ERROR: Arg [${o}] not recognized.`+app.colors.nc),console.info(`
10
- ${app.colors.by}Valid arguments are below.`+app.colors.nc),f.help(["flags","paramOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>app.regex.infoCmds.help.test(e)))f.help();else if(process.argv.some(e=>app.regex.infoCmds.version.test(e)))f.version();else{let[c="",a=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),o=l.resolve(process.cwd(),c);c&&!t.existsSync(o)&&(n=o+".scss",t.existsSync(n)?o=n:(console.error(`
11
- ${app.colors.br}Error: First argument can only be an existing file or directory.`,`
12
- '${o}' does not exist.`+app.colors.nc),console.info(`
13
- ${app.colors.bg}Example valid command:
14
- » scss-to-css . output.min.css`+app.colors.nc),f.helpCmdAndDocURL(),process.exit(1)));var p,n=o.endsWith(".scss")&&!t.statSync(o).isDirectory()?[o]:r.findSCSS(o,{recursive:!app.config.noRecursion,verbose:!app.config.quietMode,ignores:(app.config.ignores?.split(",")??[]).map(e=>e.trim())});if(app.config.dryRun)n.length?(console.info(`
15
- ${app.colors.by}SCSS files to be compiled:`+app.colors.nc),n.forEach(e=>console.info(e))):console.info(app.colors.by+`
16
- No SCSS files will be compiled.`+app.colors.nc);else{let s=[],e=[];!app.config.relativeOutput&&t.statSync(o).isDirectory()?(p=r.compile(o,{verbose:!app.config.quietMode,minify:!app.config.noMinify,comment:app.config.comment?.replace(/\\n/g,"\n"),relativeOutput:!1,recursive:!app.config.noRecursion,dotFolders:!!app.config.includeDotFolders,sourceMaps:!app.config.noSourceMaps,ignores:app.config.ignores?app.config.ignores.split(",").map(e=>e.trim()):[]}),Array.isArray(p)&&(e=p),p&&(p.error?s.push(o):e=[].concat(p))):e=n.map(e=>{var o=r.compile(e,{verbose:!app.config.quietMode,minify:!app.config.noMinify,sourceMaps:!app.config.noSourceMaps,comment:app.config.comment?.replace(/\\n/g,"\n")});return o.error&&s.push(e),o}).filter(e=>!e.error),e?.length?(p=1<e.length?"s":"",f.ifNotQuiet(`
17
- ${app.colors.bg}Compilation complete!`+app.colors.nc),f.ifNotQuiet(""+app.colors.bw+e.length+" CSS file"+p+(app.config.noSourceMaps?"":` + ${e.length} source map`+p)+" generated."+app.colors.nc)):f.ifNotQuiet(`
18
- ${app.colors.by}No SCSS files processed.`+app.colors.nc),s.length&&(f.ifNotQuiet(`
19
- `+app.colors.br+s.length+" file"+(1<s.length?"s":"")+" failed to compile:"+app.colors.nc),s.forEach(e=>f.ifNotQuiet(e))),e?.length&&(app.config.copy&&1==e?.length?(console.log(`
20
- `+app.colors.bw+e[0].code+app.colors.nc),f.ifNotQuiet("\nCopying to clipboard..."),i.writeSync(e[0].code)):(f.ifNotQuiet(`
21
- Writing to file${1<e?.length?"s":""}...`),e?.forEach(({code:e,srcMap:o,srcPath:s,relPath:i})=>{let r,p;if(!app.config.relativeOutput&&i){let e=l.resolve(process.cwd(),a||"css"),o=l.dirname(i);r="."!=o?l.join(e,o):e,p=l.basename(s,".scss")+`${app.config.noMinify?"":".min"}.css`}else r=l.join(l.dirname(s),a.endsWith(".css")?l.dirname(a):a||"css"),p=`${a.endsWith(".css")&&c.endsWith(".scss")?l.basename(a).replace(/(\.min)?\.css$/,""):l.basename(s,".scss")}.min.css`;let n=l.join(r,p);t.existsSync(r)||t.mkdirSync(r,{recursive:!0}),t.writeFileSync(n,e,"utf8"),f.ifNotQuiet(` ${app.colors.bg}✓${app.colors.nc} `+l.relative(process.cwd(),n)),app.config.noSourceMaps||t.writeFileSync(n+".map",JSON.stringify(o),"utf8"),f.ifNotQuiet(` ${app.colors.bg}✓${app.colors.nc} `+l.relative(process.cwd(),n))})))}}})();
7
+ (async()=>{var e,s=process.argv.slice(2);globalThis.env={debugMode:s.some(e=>/^--?debug(?:-?mode)?$/.test(e)),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)};let o=require("node-clipboardy"),c=require("fs"),{generateRandomLang:i,getMsgs:n,getSysLang:r}=require(`./lib/language${env.devMode?"":".min"}.js`),t=require(`./lib/log${env.devMode?"":".min"}.js`),a=require("path"),p=require(`../scss-to-css${env.devMode?"":".min"}.js`),g=require(`./lib/settings${env.devMode?"":".min"}.js`);Object.assign(globalThis.app??={},require(`../${env.devMode?"../":"./data/"}app.json`)),t.debug(app.msgs=await n(env.debugMode?i({excludes:["en"]}):r())),app.urls.docs+="/#-command-line-usage";for(e of s){if(g.controls.init.regex.test(e))return g.initConfigFile();if(g.controls.help.regex.test(e))return t.help();if(g.controls.version.regex.test(e))return t.version()}let[l="",f=""]=s.filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),d=a.resolve(process.cwd(),l);l&&!c.existsSync(d)&&(s=d+".scss",c.existsSync(s)?d=s:(t.error(`${app.msgs.error_firstArgNotExist}.\n${d} ${app.msgs.error_doesNotExist}.`),t.success(app.msgs.info_exampleValidCmd+`:
8
+ » scss-to-css . output.min.css`),t.helpCmdAndDocURL(),process.exit(1))),g.load();var m,s=d.endsWith(".scss")&&!c.statSync(d).isDirectory()?[d]:p.findSCSS(d,{recursive:!app.config.noRecursion,verbose:!app.config.quietMode,ignores:(app.config.ignores?.split(",")??[]).map(e=>e.trim())});if(app.config.dryRun)s.length?(t.info(app.msgs.info_scssFilesToBeCompiled+":"),s.forEach(e=>console.info(e))):t.info(`
9
+ ${app.msgs.info_noSCSSfilesWillBeCompiled}.`);else{let i=[],e=[];!app.config.relativeOutput&&c.statSync(d).isDirectory()?(m=p.compile(d,{verbose:!app.config.quietMode,minify:!app.config.noMinify,comment:app.config.comment?.replace(/\\n/g,"\n"),relativeOutput:!1,recursive:!app.config.noRecursion,dotFolders:!!app.config.includeDotFolders,sourceMaps:!app.config.noSourceMaps,ignores:app.config.ignores?app.config.ignores.split(",").map(e=>e.trim()):[]}),Array.isArray(m)&&(e=m),m&&(m.error?i.push(d):e=[].concat(m))):e=s.map(e=>{var s=p.compile(e,{verbose:!app.config.quietMode,minify:!app.config.noMinify,sourceMaps:!app.config.noSourceMaps,comment:app.config.comment?.replace(/\\n/g,"\n")});return s.error&&i.push(e),s}).filter(e=>!e.error),app.config.quietMode||(s=1==(m=e.length)?"":"s",m?(t.success(app.msgs.info_compilationComplete+"!"),t.data(`${m} CSS ${app.msgs.info_file}${s}${app.config.noSourceMaps?"":` + ${m} `+app.msgs.info_srcMap+s} ${app.msgs.info_generated}.`)):console.info(app.msgs.info_noSCSSfilesProcessed+"."),i.length&&(t.error(i.length+" "+app.msgs.info_file+(1==i.length?"":"s"),app.msgs.info_failedToCompile+":"),i.forEach(e=>t.ifNotQuiet(e)))),e?.length&&(app.config.copy&&1==e?.length?(t.data(e[0].code),t.ifNotQuiet(`
10
+ ${app.msgs.info_copying}...`),o.writeSync(e[0].code)):(t.ifNotQuiet(`
11
+ ${app.msgs.info_writing}${1<e?.length?"s":""}...`),e?.forEach(({code:e,srcMap:s,srcPath:i,relPath:o})=>{let n,r;if(!app.config.relativeOutput&&o){let e=a.resolve(process.cwd(),f||"css"),s=a.dirname(o);n="."!=s?a.join(e,s):e,r=`${a.basename(i,".scss")}${app.config.noMinify?"":".min"}.css`}else n=a.join(a.dirname(i),f.endsWith(".css")?a.dirname(f):f||"css"),r=`${f.endsWith(".css")&&l.endsWith(".scss")?a.basename(f).replace(/(\.min)?\.css$/,""):a.basename(i,".scss")}.min.css`;let p=a.join(n,r);c.mkdirSync(n,{recursive:!0}),c.writeFileSync(p,e,"utf8"),t.ifNotQuiet(` ${t.colors.bg}✓${t.colors.nc} `+a.relative(process.cwd(),p)),app.config.noSourceMaps||c.writeFileSync(p+".map",JSON.stringify(s),"utf8"),t.ifNotQuiet(` ${t.colors.bg}✓${t.colors.nc} ${a.relative(process.cwd(),p)}.map`)})))}})();
@@ -0,0 +1,6 @@
1
+ /**
2
+ * © 2024–2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/scss-to-css/tree/main/src
4
+ * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
5
+ */
6
+ module.exports={atomicWrite(e,r,t="utf8"){var n=require("path"),a=require("fs"),n=n.join(n.dirname(e),`.${n.basename(e)}.tmp`);a.writeFileSync(n,r,t),a.renameSync(n,e)},fetch(n){return"undefined"==typeof fetch?new Promise((t,e)=>{var r=n.match(/^([^:]+):\/\//)[1];/^https?$/.test(r)||e(new Error(app.msgs.error_invalidURL+".")),require(r).get(n,e=>{let r="";e.on("data",e=>r+=e),e.on("end",()=>t({json:()=>JSON.parse(r)}))}).on("error",e)}):fetch(n)},flatten(e,{key:r="message"}={}){var t,n={};for(t in e)n[t]="object"==typeof e[t]&&r in e[t]?e[t][r]:e[t];return n}};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * © 2024–2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/scss-to-css/tree/main/src
4
+ * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
5
+ */
6
+ let data=require(`./data${env.devMode?"":".min"}.js`);module.exports={generateRandomLang({includes:e=[],excludes:a=[]}={}){let s=require("fs"),r=require(`./log${env.devMode?"":".min"}.js`),t=require("path"),n=e.length?e:(()=>{var e=t.join(__dirname,"..",".cache"),a=t.join(e,"locales.json");if(s.existsSync(a))try{return JSON.parse(s.readFileSync(a,"utf8"))}catch(e){}var r=t.resolve(process.cwd(),"_locales");return s.existsSync(r)?(r=s.readdirSync(r,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).filter(e=>/^[a-z]{2}(?:_[A-Z]{2})?$/.test(e)),s.mkdirSync(e,{recursive:!0}),data.atomicWrite(a,JSON.stringify(r,null,2)),r):["en"]})(),l=new Set(a),i="en";return(n=n.filter(e=>!l.has(e))).length&&(i=n[Math.floor(Math.random()*n.length)]),r.debug(`
7
+ Random language: ${i}
8
+ `),i},async getMsgs(s="en"){let e=data.flatten(require(`../../${env.devMode?"../_locales/en/":"data/"}messages.json`),{key:"message"});if(!s.startsWith("en")){var t=`${app.urls.jsdelivr}@${app.commitHashes.locales}/_locales/`;let a=t+s.replace("-","_")+"/messages.json",r=0;for(;r<3;)try{e=data.flatten(await(await data.fetch(a)).json(),{key:"message"});break}catch(e){if(2<++r)break;a=s.includes("-")&&1==r?a.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):t+"en/messages.json"}}return e},getSysLang(){var e;if("win32"!=process.platform)return((e=process.env).LANG||e.LANGUAGE||e.LC_ALL||e.LC_MESSAGES||e.LC_NAME||"en").split(".")[0];try{return require("child_process").execSync("(Get-Culture).TwoLetterISOLanguageName",{shell:"powershell",encoding:"utf-8"}).trim()}catch(e){return console.error("ERROR loading system language:",e.message),"en"}}};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * © 2024–2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/scss-to-css/tree/main/src
4
+ * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
5
+ */
6
+ module.exports={colors:{nc:"",br:"",by:"",bo:"",bg:"",bw:"",blk:"",tlBG:""},configURL(){this.info(`
7
+ ${app.msgs.info_exampleValidConfigFile}: `+app.urls.config)},configURLandExit(...s){this.error(...s),this.configURL(),process.exit(1)},data(s){console.log(`
8
+ `+this.colors.bw+s+this.colors.nc)},debug(s){env.debugMode&&console.log(s)},error(...s){console.error(`
9
+ ${this.colors.br}${app.msgs.prefix_error}:`,...s,this.colors.nc)},errorAndExit(...s){this.error(...s),this.helpCmdAndDocURL(),process.exit(1)},ifNotQuiet(s){app.config.quietMode||console.info(s)},info(s){console.info(`
10
+ `+this.colors.by+s+this.colors.nc)},tip(s){console.info(""+this.colors.by+app.msgs.prefix_tip+": "+s+this.colors.nc)},success(s){console.log(`
11
+ `+this.colors.bg+s+this.colors.nc)},warn(...s){console.warn(`
12
+ ${this.colors.bo}${app.msgs.prefix_warning}:`,...s,this.colors.nc)},help(s=["header","usage","pathArgs","flags","params","cmds"]){app.prefix=""+this.colors.tlBG+this.colors.blk+` ${app.name.replace(/^@[^/]+\//,"")} ${this.colors.nc} `;let o={header:[`
13
+ ├ ${app.prefix}${app.msgs.appCopyright}.`,""+app.prefix+app.msgs.prefix_source+": "+app.urls.src],usage:[`
14
+ ${this.colors.bw}o ${app.msgs.helpSection_usage}:`+this.colors.nc,` ${this.colors.bw}» `+this.colors.bg+app.cmdFormat+this.colors.nc],pathArgs:[`
15
+ ${this.colors.bw}o ${app.msgs.helpSection_pathArgs}:`+this.colors.nc,` [inputPath] ${app.msgs.inputPathDesc_main}, ${app.msgs.inputPathDesc_extra}.`,` [outputPath] ${app.msgs.outputPathDesc_main}, `+app.msgs.outputPathDesc_extra],flags:[`
16
+ ${this.colors.bw}o ${app.msgs.helpSection_flags}:`+this.colors.nc,` -n, --dry-run ${app.msgs.optionDesc_dryRun}.`,` -d, --include-dotfolders ${app.msgs.optionDesc_dotfolders}.`,` -S, --no-source-maps ${app.msgs.optionDesc_noSourceMaps}.`,` -M, --no-minify ${app.msgs.optionDesc_noMinify}.`,` -R, --no-recursion ${app.msgs.optionDesc_noRecursion}.`,` -r, --relative-output ${app.msgs.optionDesc_relativeOutput}.`,` -c, --copy ${app.msgs.optionDesc_copy}.`,` -q, --quiet ${app.msgs.optionDesc_quiet}.`],params:[`
17
+ ${this.colors.bw}o ${app.msgs.helpSection_params}:`+this.colors.nc,`--ignores="dir/,file1.scss,file2.scss" ${app.msgs.optionDesc_ignores}.`,`--comment="comment" ${app.msgs.optionDesc_commentMain}. ${app.msgs.optionDesc_commentExtra}.`,` --config="path/to/file" ${app.msgs.optionDesc_config}.`],cmds:[`
18
+ ${this.colors.bw}o ${app.msgs.helpSection_cmds}:`+this.colors.nc,` -i, --init ${app.msgs.optionDesc_init}.`,` -h, --help ${app.msgs.optionDesc_help}.`,` -v, --version ${app.msgs.optionDesc_version}.`]};s.forEach(t=>o[t]?.forEach(o=>{{var r=/header|usage/.test(t)?1:41;let p=process.stdout.columns||80,s=o.match(/\S+|\s+/g),e=[],i="";s.forEach(s=>{var o=p-(e.length?r:0);i.length+"| ".length+s.length>o&&(e.push(e.length?i.trimStart():i),i=""),i+=s}),e.push(e.length?i.trimStart():i),e.forEach((s,o)=>console.info("| "+(0==o?s:" ".repeat(r)+s)))}})),console.info(`
19
+ ${app.msgs.info_moreHelp}, ${app.msgs.info_visit}: `+this.colors.bw+app.urls.docs+this.colors.nc)},helpCmdAndDocURL(){console.info(`
20
+ ${app.msgs.info_moreHelp}, ${app.msgs.info_type} ${app.name.split("/")[1]} --help' ${app.msgs.info_or} ${app.msgs.info_visit}
21
+ `+this.colors.bw+app.urls.docs+this.colors.nc)},version(){var s=require("path"),o=require("child_process").execSync(`npm view ${JSON.stringify(app.name)} version`).toString().trim()||"none";let p,e=process.cwd();for(;"/"!=e;){var i=s.join(e,"package.json");if(require("fs").existsSync(i)){i=require(i);p=(i.dependencies?.[app.name]||i.devDependencies?.[app.name])?.match(/^[~^>=]?\d+\.\d+\.\d+$/)[1]||"none";break}e=s.dirname(e)}console.info(`
22
+ ${app.msgs.prefix_globalVer}: ${o}
23
+ ${app.msgs.prefix_localVer}: `+p)}};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * © 2024–2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/scss-to-css/tree/main/src
4
+ * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
5
+ */
6
+ let fs=require("fs"),log=require(`./log${env.devMode?"":".min"}.js`),path=require("path");(globalThis.app??={}).config={},module.exports={configFilename:"scss-to-css.config.mjs",controls:{dryRun:{type:"flag",regex:/^--?(?:n|dry-?run)$/},includeDotFolders:{type:"flag",regex:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/},noSourceMaps:{type:"flag",regex:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/},noRecursion:{type:"flag",regex:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/},noMinify:{type:"flag",regex:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/},relativeOutput:{type:"param",regex:/^--?(?:r|relative-?output?=?(?:true|1)?)$/},copy:{type:"param",regex:/^--?c(?:opy)?$/},quietMode:{type:"param",regex:/^--?q(?:uiet)?(?:-?mode)?$/},ignores:{type:"param",regex:/^--?(?:ignores?|(?:ignore|skip|exclude)(?:d?-?files?)?)(?:=.*|$)/},comment:{type:"param",regex:/^--?comments?(?:=.*|$)/},config:{type:"param",regex:/^--?config(?:=.*|$)/},init:{type:"cmd",regex:/^-{0,2}i(?:nit)?$/},help:{type:"cmd",regex:/^--?h(?:elp)?$/},version:{type:"cmd",regex:/^--?ve?r?s?i?o?n?$/}},async initConfigFile(e=this.configFilename){var r=path.resolve(process.cwd(),e);if(fs.existsSync(r))return log.warn(app.msgs.warn_configFileExists+":",r);var i=path.resolve(__dirname,"../../"+(env.devMode?"../":"./data/")+e);if(fs.existsSync(i))fs.copyFileSync(i,r);else{i=app.urls.jsdelivr+"/"+e;log.data(app.msgs.info_fetchingRemoteConfigFrom+` ${i}...`);try{var o=await require(`./data${env.devMode?"":".min"}.js`).fetch(i);if(!o.ok)return log.warn(`${app.msgs.warn_remoteConfigNotFound}: ${i} (${o.status})`);require(`./data${env.devMode?"":".min"}.js`).atomicWrite(r,await o.text())}catch(e){return log.warn(app.msgs.warn_remoteConfigFailed+`: ${i} `+e.message)}}log.success(app.msgs.info_configFileCreated+`: ${r}
7
+ `),log.tip(app.msgs.tip_editToSetDefaults+"."),log.tip(app.msgs.tip_cliArgsPrioritized+".")},load({args:e=process.argv.slice(2),ctrlKeys:s=Object.keys(this.controls)}={}){let r=null;var i=e.find(e=>this.controls.config.regex.test(e));if(i){/=/.test(i)||log.errorAndExit(`[${i}] `+app.msgs.error_mustIncludePath);i=i.split("=")[1];r=path.isAbsolute(i)?i:path.resolve(process.cwd(),i),fs.existsSync(r)||log.configURLandExit(app.msgs.error_configFileNotFound+":",r)}else for(var o of["mjs","cjs","js"]){o=path.resolve(process.cwd(),this.configFilename.replace(/\.[^.]+$/,"."+o));if(fs.existsSync(o)){r=o;break}}if(r)try{var t=require(r),a=t?.default??t;a&&"object"==typeof a||log.configURLandExit(app.msgs.error_invalidConfigFile+"."),Object.assign(app.config,a)}catch(e){log.configURLandExit(app.msgs.error_failedToLoadConfigFile+":",r,`
8
+ `+e.message)}return e.forEach(r=>{if(!/^[^-]|--?(?:config|debug)/.test(r)){var i=s.find(e=>this.controls[e]?.regex?.test(r)),o=(i||log.errorAndExit(`[${r}] ${app.msgs.error_notRecognized}.`),this.controls[i]);if("cmd"!=o.type){let e="param"!=o.type||r.split("=")[1]?.trim();o.mode?app.config.mode=i.replace(/mode$/i,"").toLowerCase():((o=o.parser)&&(e=o(e),isNaN(e)||e<1)&&log.errorAndExit(`[${i}] ${app.msgs.error_nonPositiveNum}.`),app.config[i]=e)}}}),app.config}};
@@ -5,10 +5,14 @@
5
5
  "copyrightYear": "2024–2026",
6
6
  "cmdFormat": "scss-to-css [inputPath] [outputPath] [options]",
7
7
  "urls": {
8
+ "config": "https://github.com/adamlui/scss-to-css/blob/main/scss-to-css.config.mjs",
8
9
  "docs": "https://github.com/adamlui/scss-to-css/tree/main/docs",
9
10
  "github": "https://github.com/adamlui/scss-to-css",
10
11
  "jsdelivr": "https://cdn.jsdelivr.net/gh/adamlui/scss-to-css",
11
12
  "npm": "https://www.npmjs.com/package/@adamlui/scss-to-css",
12
13
  "src": "https://github.com/adamlui/scss-to-css/tree/main/src"
14
+ },
15
+ "commitHashes": {
16
+ "locales": "ca10f06"
13
17
  }
14
18
  }
@@ -0,0 +1,66 @@
1
+ {
2
+ "appName": { "message": "scss-to-css" },
3
+ "appCopyright": { "message": "© 2024–2026 Adam Lui & contributors under the MIT license" },
4
+ "prefix_error": { "message": "ERROR" },
5
+ "prefix_tip": { "message": "TIP" },
6
+ "prefix_warning": { "message": "WARNING" },
7
+ "prefix_globalVer": { "message": "Global version" },
8
+ "prefix_localVer": { "message": "Local version" },
9
+ "prefix_source": { "message": "Source" },
10
+ "error_notRecognized": { "message": "not recognized" },
11
+ "error_nonPositiveNum": { "message": "argument can only be > 0" },
12
+ "error_invalidURL": { "message": "Invalid URL" },
13
+ "error_invalidConfigFile": { "message": "Config file must export an object" },
14
+ "error_configFileNotFound": { "message": "Config file not found" },
15
+ "error_failedToLoadConfigFile": { "message": "Failed to load config file" },
16
+ "error_mustIncludePath": { "message": "must include =path" },
17
+ "warn_configFileExists": { "message": "Config file already exists" },
18
+ "info_exampleValidConfigFile": { "message": "Example valid config file" },
19
+ "error_firstArgNotExist": { "message": "First argument can only be an existing file or directory" },
20
+ "error_doesNotExist": { "message": "does not exist" },
21
+ "info_exampleValidCmd": { "message": "Example valid command" },
22
+ "info_scssFilesToBeCompiled": { "message": "SCSS files to be compiled" },
23
+ "info_noSCSSfilesWillBeCompiled": { "message": "No SCSS files will be compiled" },
24
+ "info_copying": { "message": "Copying to clipboard" },
25
+ "info_writing": { "message": "Writing to file" },
26
+ "info_compilationComplete": { "message": "Compilation complete" },
27
+ "info_file": { "message": "file" },
28
+ "info_srcMap": { "message": "source map" },
29
+ "info_generated": { "message": "generated" },
30
+ "info_noSCSSfilesProcessed": { "message": "No SCSS files processed" },
31
+ "info_failedToCompile": { "message": "failed to compile" },
32
+ "info_moreHelp": { "message": "For more help" },
33
+ "info_type": { "message": "type" },
34
+ "info_or": { "message": "or" },
35
+ "info_visit": { "message": "visit" },
36
+ "info_configFileCreated": { "message": "Config file created" },
37
+ "info_fetchingRemoteConfigFrom": { "message": "Fetching remote config file from" },
38
+ "warn_remoteConfigNotFound": { "message": "Remote config file not found" },
39
+ "warn_remoteConfigFailed": { "message": "Remote config file not found" },
40
+ "tip_editToSetDefaults": { "message": "Edit this file to customize defaults" },
41
+ "tip_cliArgsPrioritized": { "message": "CLI arguments always override these values" },
42
+ "helpSection_usage": { "message": "Usage" },
43
+ "helpSection_pathArgs": { "message": "Path arguments" },
44
+ "helpSection_flags": { "message": "Boolean options" },
45
+ "helpSection_params": { "message": "Parameter options" },
46
+ "helpSection_cmds": { "message": "Commands" },
47
+ "inputPathDesc_main": { "message": "Path to SCSS file or directory containing SCSS files to be compiled" },
48
+ "inputPathDesc_extra": { "message": "relative to the current working directory" },
49
+ "outputPathDesc_main": { "message": "Path to file or directory where CSS + sourcemap files will be stored" },
50
+ "outputPathDesc_extra": { "message": "relative to input root (if not provided, css/ is used)" },
51
+ "optionDesc_dryRun": { "message": "Don't actually compile the file(s), just show if they will be processed" },
52
+ "optionDesc_dotfolders": { "message": "Include dotfolders in file search" },
53
+ "optionDesc_noSourceMaps": { "message": "Prevent source maps from being generated" },
54
+ "optionDesc_noMinify": { "message": "Disable minification of output CSS" },
55
+ "optionDesc_noRecursion": { "message": "Disable recursive file searching" },
56
+ "optionDesc_copy": { "message": "Copy compiled CSS to clipboard instead of writing to file if single source file is processed" },
57
+ "optionDesc_relativeOutput": { "message": "Output files relative to each source file instead of to input root" },
58
+ "optionDesc_quiet": { "message": "Suppress all logging except errors" },
59
+ "optionDesc_ignores": { "message": "Files/directories to exclude from compilation" },
60
+ "optionDesc_commentMain": { "message": "Prepend header comment to compiled CSS" },
61
+ "optionDesc_commentExtra": { "message": "Separate by line using '\\n'" },
62
+ "optionDesc_config": { "message": "Load custom config file" },
63
+ "optionDesc_init": { "message": "Create config file (in project root)" },
64
+ "optionDesc_help": { "message": "Display help screen" },
65
+ "optionDesc_version": { "message": "Show version number" }
66
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * scss-to-css.config.mjs
3
+ *
4
+ * Optional config file for the scss-to-css CLI.
5
+ * Copy this file to your project root to set default options.
6
+ * CLI arguments always override these values.
7
+ *
8
+ * Docs: https://github.com/adamlui/scss-to-css/#-command-line-usage
9
+ */
10
+
11
+ export default {
12
+
13
+ // Boolean options
14
+ dryRun: false, // don't actually minify the file(s), just show if they will be processed
15
+ includeDotFolders: false, // include dotfolders in file search
16
+ noSourceMaps: false, // prevent source maps from being generated
17
+ noMinify: false, // disable minification of output CSS
18
+ noRecursion: false, // disable recursive file searching
19
+ relativeOutput: false, // output files relative to each src file instead of to input root
20
+ copy: false, // copy compiled CSS to clipboard instead of write to file if single file processed
21
+ quietMode: false, // suppress all logging except errors
22
+
23
+ // String params
24
+ ignores: '', // files/dirs to exclude from minification
25
+ comment: '' // header comment to prepend to minified code
26
+ }
@@ -1,9 +1,9 @@
1
1
  /**
2
- * © 2024 Adam Lui & contributors under the MIT license.
3
- * Source: https://github.com/adamlui/scss-to-css/tree/main/src
4
- * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
2
+ * © 2024–2026 Adam Lui & contributors under the MIT license.
3
+ * Source: https://github.com/adamlui/scss-to-css/tree/main/src
4
+ * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
5
5
  */
6
- let fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(r,i={}){var e="https://github.com/adamlui/scss-to-css/tree/main/docs/#findscsssearchdir-options",o={recursive:!0,verbose:!0,dotFolders:!1,ignores:[]};if(log.prefix="findSCSS()","string"!=typeof r)return log.error("1st arg <searchDir> must be a string."),log.helpURL(e);var s=path.resolve(process.cwd(),r);if(!fs.existsSync(s))return log.error("1st arg <searchDir> must be an existing directory."),log.error(s+" does not exist."),log.helpURL(e);if(validateOptions({options:i,defaultOptions:o,helpURL:e,exampleCall:"findSCSS('assets/scss', { verbose: false, dotFolders: true })"})){(i={...o,...i}).ignoreFiles&&(i.ignores=[...i.ignores,...i.ignoreFiles]);let e=fs.readdirSync(r),s=[];return i.verbose&&!i.isRecursing&&log.info("Searching for SCSS files..."),e.forEach(e=>{let o=path.resolve(r,e);i.ignores.some(s=>s.endsWith("/")?o.split(path.sep).some(e=>e==s.replace(/\/$/,"")):e==s)?i.verbose&&log.info(`** ${e} ignored`):fs.statSync(o).isDirectory()&&"node_modules"!=e&&i.recursive&&(i.dotFolders||!e.startsWith("."))?s.push(...findSCSS(o,{...i,isRecursing:!0})):e.endsWith(".scss")&&s.push(o)}),i.verbose&&!i.isRecursing&&(log.info("Search complete!",`${s.length||"No"} file${1==s.length?"":"s"} found.`),"compile"!=findSCSS.caller?.name)&&"undefined"!=typeof window&&log.info("Check returned array."),i.isRecursing||s.length?s:[]}}function compile(i,t={}){var e="https://github.com/adamlui/scss-to-css/tree/main/docs/#compileinput-options",s={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0,relativeOutput:!1,ignores:[],comment:""};if(log.prefix="compile()","string"!=typeof i)return log.error("1st arg <input> must be a string."),log.helpURL(e);if(validateOptions({options:t,defaultOptions:s,helpURL:e,exampleCall:"compile('assets/scss', { recursive: false, minify: false })"})){(t={...s,...t}).ignoreFiles&&(t.ignores=[...t.ignores,...t.ignoreFiles]);let r={style:t.minify?"compressed":"expanded",sourceMap:t.sourceMaps,charset:!1};if(fs.existsSync(i)){if(!i.endsWith(".scss")||!fs.statSync(i).isFile())return e=findSCSS(i,t)?.map(e=>{t.verbose&&log.info(`** Compiling ${e}...`);try{var s=sass.compile(e,r),o=t.relativeOutput?void 0:path.relative(path.resolve(process.cwd(),i),e);return t.comment&&(s.css=prependComment(s.css,t.comment)),{code:s.css,srcMap:s.sourceMap,srcPath:e,relPath:o,error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}).filter(e=>!e.error),t.verbose&&(e.length&&"undefined"!=typeof window?log.info("Compilation complete! Check returned object."):log.info("No SCSS files processed.")),e;t.verbose&&log.info(`** Compiling ${i}...`);try{var o=sass.compile(i,r);return t.comment&&(o.css=prependComment(o.css,t.comment)),t.verbose&&"undefined"!=typeof window&&log.info("Compilation complete! Check returned object."),{code:o.css,srcMap:o.sourceMap,srcPath:path.resolve(process.cwd(),i),error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}else{t.verbose&&log.info("** Compiling passed source code...");try{var n=sass.compileString(i,r);return t.comment&&(n.css=prependComment(n.css,t.comment)),{code:n.css,srcMap:n.sourceMap,srcPath:void 0,error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}}}function prependComment(e,s){var o=e.match(/^#!.*\n/);let r="";return o&&(r=o[0],e=e.slice(r.length)),`${r}/**
6
+ let fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(r,i={}){var e="https://github.com/adamlui/scss-to-css/tree/main/docs/#findscsssearchdir-options",o={recursive:!0,verbose:!0,dotFolders:!1,ignores:[]};if(log.prefix="findSCSS()","string"!=typeof r)return log.error("1st arg <searchDir> must be a string."),log.helpURL(e);var s=path.resolve(process.cwd(),r);if(!fs.existsSync(s))return log.error("1st arg <searchDir> must be an existing directory."),log.error(s+" does not exist."),log.helpURL(e);if(validateOptions({options:i,defaultOptions:o,helpURL:e,exampleCall:"findSCSS('assets/scss', { verbose: false, dotFolders: true })"})){(i={...o,...i}).ignoreFiles&&(i.ignores=[...i.ignores,...i.ignoreFiles]);let e=fs.readdirSync(r),s=[];return i.verbose&&!i.isRecursing&&log.info("Searching for SCSS files..."),e.forEach(e=>{let o=path.resolve(r,e);i.ignores.some(s=>s.endsWith("/")?o.split(path.sep).some(e=>e==s.replace(/\/$/,"")):e==s)?i.verbose&&log.info(`** ${e} ignored`):fs.statSync(o).isDirectory()&&"node_modules"!=e&&i.recursive&&(i.dotFolders||!e.startsWith("."))?s.push(...findSCSS(o,{...i,isRecursing:!0})):e.endsWith(".scss")&&s.push(o)}),i.verbose&&!i.isRecursing&&(log.info("Search complete!",`${s.length||"No"} file${1==s.length?"":"s"} found.`),"compile"!=findSCSS.caller?.name)&&"undefined"!=typeof window&&log.info("Check returned array."),i.isRecursing||s.length?s:[]}}function compile(i,t={}){var e="https://github.com/adamlui/scss-to-css/tree/main/docs/#compileinput-options",s={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0,relativeOutput:!1,ignores:[],comment:""};if(log.prefix="compile()","string"!=typeof i)return log.error("1st arg <input> must be a string."),log.helpURL(e);if(validateOptions({options:t,defaultOptions:s,helpURL:e,exampleCall:"compile('assets/scss', { recursive: false, minify: false })"})){(t={...s,...t}).ignoreFiles&&(t.ignores=[...t.ignores,...t.ignoreFiles]);let r={style:t.minify?"compressed":"expanded",sourceMap:t.sourceMaps,charset:!1};if(fs.existsSync(i)){if(!i.endsWith(".scss")||!fs.statSync(i).isFile())return e=findSCSS(i,t)?.map(e=>{t.verbose&&log.info(`** Compiling ${e}...`);try{var s=sass.compile(e,r),o=t.relativeOutput?void 0:path.relative(path.resolve(process.cwd(),i),e);return t.comment&&(s.css=prependComment(s.css,t.comment)),{code:s.css,srcMap:s.sourceMap,srcPath:e,relPath:o,error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}).filter(e=>!e.error),t.verbose&&(e.length&&"undefined"!=typeof window?log.info("Compilation complete! Check returned object."):log.info("No SCSS files processed.")),e;t.verbose&&log.info(`** Compiling ${i}...`);try{var o=sass.compile(i,r);return t.comment&&(o.css=prependComment(o.css,t.comment)),t.verbose&&"undefined"!=typeof window&&log.info("Compilation complete! Check returned object."),{code:o.css,srcMap:o.sourceMap,srcPath:path.resolve(process.cwd(),i),error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}else{t.verbose&&log.info("** Compiling passed source code...");try{var n=sass.compileString(i,r);return t.comment&&(n.css=prependComment(n.css,t.comment)),{code:n.css,srcMap:n.sourceMap,srcPath:void 0,error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}}}function prependComment(e,s){let o="";var r=e.match(/^#!.*\n/);return r&&(o=r[0],e=e.slice(o.length)),`${o}/**
7
7
  ${s.split("\n").map(e=>" * "+e).join("\n")}
8
8
  */
9
- `+e}function validateOptions({options:e,defaultOptions:s,helpURL:o,exampleCall:r}){var i,t,n=Object.keys(s).filter(e=>"boolean"==typeof s[e]),l=Object.keys(s).filter(e=>Number.isInteger(s[e]));if("object"!=typeof e)return i=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,i+=["st","nd","rd"][i-1]||"th",log.error(`${"0th"==i?"[O":i+" arg [o"}ptions] can only be an object of key/vals.`),log.info("Example valid call:",r),log.validOptions(s),log.helpURL(o),!1;for(t in e)if("isRecursing"!=t&&Object.prototype.hasOwnProperty.call(s,t)){if(n.includes(t)&&"boolean"!=typeof e[t])return log.error(`[${t}] option can only be \`true\` or \`false\`.`),log.helpURL(o),!1;if(l.includes(t)&&(e[t]=parseInt(e[t],10),isNaN(e[t])||e[t]<1))return log.error(`[${t}] option can only be an integer > 0.`),log.helpURL(o),!1}return!0}Object.assign(globalThis.app??={},require(`${__dirname.match(/[\\/]src/)?"../":"./data/"}app.json`)),app.aliases={compile:["build","Build","Compile","compress","Compress","minify","Minify"],findSCSS:["find","Find","findscss","findScss","Findscss","FindScss","FindSCSS","search","Search"]};let log={prefix:app.name,error(...e){console.error(this.prefix+" » ERROR:",...e)},helpURL(e=app.urls?.docs){this.info("For more help, please visit",e)},info(...e){console.info(this.prefix+" »",...e)},validOptions(e){var s=Object.keys(e).join(", "),e=JSON.stringify(e,void 0,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," ");this.info(`Valid options: [${s}]`),this.info("If omitted, default settings are: "+e)}};module.exports={compile:compile,findSCSS:findSCSS};for(let s in app.aliases)app.aliases[s].forEach(e=>module.exports[e]=module.exports[s]);
9
+ `+e}function validateOptions({options:e,defaultOptions:s,helpURL:o,exampleCall:r}){var i,t,n=Object.keys(s).filter(e=>"boolean"==typeof s[e]),l=Object.keys(s).filter(e=>Number.isInteger(s[e]));if("object"!=typeof e)return i=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,i+=["st","nd","rd"][i-1]||"th",log.error(`${"0th"==i?"[O":i+" arg [o"}ptions] can only be an object of key/vals.`),log.info("Example valid call:",r),log.validOptions(s),log.helpURL(o),!1;for(t in e)if("isRecursing"!=t&&Object.prototype.hasOwnProperty.call(s,t)){if(n.includes(t)&&"boolean"!=typeof e[t])return log.error(`[${t}] option can only be \`true\` or \`false\`.`),log.helpURL(o),!1;if(l.includes(t)&&(e[t]=parseInt(e[t],10),isNaN(e[t])||e[t]<1))return log.error(`[${t}] option can only be an integer > 0.`),log.helpURL(o),!1}return!0}Object.assign(globalThis.app??={},require(`${/[\\/]src(?:[\\/]|$)/i.test(__dirname)?"../":"./data/"}app.json`)),app.aliases={compile:["build","Build","Compile","compress","Compress","minify","Minify"],findSCSS:["find","Find","findscss","findScss","Findscss","FindScss","FindSCSS","search","Search"]};let log={prefix:app.name,error(...e){console.error(this.prefix+" » ERROR:",...e)},helpURL(e=app.urls?.docs){this.info("For more help, please visit",e)},info(...e){console.info(this.prefix+" »",...e)},validOptions(e){var s=Object.keys(e).join(", "),e=JSON.stringify(e,void 0,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," ");this.info(`Valid options: [${s}]`),this.info("If omitted, default settings are: "+e)}};module.exports={compile:compile,findSCSS:findSCSS};for(let s in app.aliases)app.aliases[s].forEach(e=>module.exports[e]??=module.exports[s]);
package/docs/README.md CHANGED
@@ -33,8 +33,8 @@
33
33
  <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>
34
34
  <a href="#%EF%B8%8F-mit-license">
35
35
  <img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
36
- <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.0.1">
37
- <img height=31 src="https://img.shields.io/badge/Latest_Build-2.0.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
36
+ <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.1.0">
37
+ <img height=31 src="https://img.shields.io/badge/Latest_Build-2.1.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
38
38
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code">
39
39
  <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>
40
40
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:src/scss-to-css.js">
@@ -163,11 +163,39 @@ Parameter options:
163
163
  --comment="comment" Prepend header comment to
164
164
  compiled CSS. Separate by
165
165
  line using '\n'.
166
- Info commands:
166
+ --config="path/to/file" Load custom config file.
167
+
168
+ Commands:
169
+ -i, --init Create config file (in project root).
167
170
  -h, --help Display help screen.
168
171
  -v, --version Show version number.
169
172
  ```
170
173
 
174
+ #
175
+
176
+ ### Configuration file
177
+
178
+ **scss-to-css** can be customized using a `scss-to-css.config.mjs` or `scss-to-css.config.js` placed in your project root.
179
+
180
+ Example defaults:
181
+
182
+ ```js
183
+ export default {
184
+ dryRun: false, // don't actually minify the file(s), just show if they will be processed
185
+ includeDotFolders: false, // include dotfolders in file search
186
+ noSourceMaps: false, // prevent source maps from being generated
187
+ noMinify: false, // disable minification of output CSS
188
+ noRecursion: false, // disable recursive file searching
189
+ relativeOutput: false, // output files relative to each src file instead of to input root
190
+ copy: false, // copy compiled CSS to clipboard instead of write to file if single file processed
191
+ quietMode: false, // suppress all logging except errors
192
+ ignores: '', // files/dirs to exclude from minification
193
+ comment: '' // header comment to prepend to minified code
194
+ }
195
+ ```
196
+
197
+ 💡 Run `scss-to-css init` to generate a template `scss-to-css.config.mjs` in your project root.
198
+
171
199
  <br>
172
200
 
173
201
  <img height=6px width="100%" src="https://assets.scsstocss.org/images/separators/aqua-gradient.png?v=7e4a141">
@@ -179,7 +207,7 @@ You can also import **scss-to-css** into your app to use its API methods, both a
179
207
  #### ECMAScript*:
180
208
 
181
209
  ```js
182
- import scssToCSS from '@adamlui/scss-to-css';
210
+ import scssToCSS from '@adamlui/scss-to-css'
183
211
  ```
184
212
 
185
213
  #### CJS:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/scss-to-css",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Recursively compile all SCSS files into minified CSS",
5
5
  "author": {
6
6
  "name": "Adam Lui",
@@ -47,7 +47,12 @@
47
47
  "lint:all": "eslint .",
48
48
  "lint:fix": "eslint . --fix --cache",
49
49
  "lint:fix-all": "eslint . --fix",
50
- "build": "bash utils/build.sh",
50
+ "translate": "py utils/translate-en-messages.py",
51
+ "build": "node utils/build",
52
+ "build:js": "node utils/build --js",
53
+ "build:data": "node utils/build --data",
54
+ "build:json": "node utils/build --json",
55
+ "debug": "node src/cli --debug",
51
56
  "bump:patch": "bash utils/bump.sh patch",
52
57
  "bump:minor": "bash utils/bump.sh minor",
53
58
  "bump:major": "bash utils/bump.sh major"
@@ -74,7 +79,7 @@
74
79
  "sass": "^1.97.3"
75
80
  },
76
81
  "devDependencies": {
77
- "@adamlui/minify.js": "^2.1.4",
82
+ "@adamlui/minify.js": "^2.2.0",
78
83
  "@eslint/json": "^1.0.0",
79
84
  "@eslint/markdown": "^7.5.1",
80
85
  "@stylistic/eslint-plugin": "^5.7.1",
@@ -1,17 +0,0 @@
1
- /**
2
- * © 2024 Adam Lui & contributors under the MIT license.
3
- * Source: https://github.com/adamlui/scss-to-css/tree/main/src
4
- * Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
5
- */
6
- module.exports={help(e=["header","usage","pathArgs","flags","paramOptions","infoCmds"]){app.prefix=""+app.colors.tlBG+app.colors.blk+` ${app.name.replace(/^@[^/]+\//,"")} ${app.colors.nc} `;let o={header:[`
7
- ├ ${app.prefix}© ${app.copyrightYear} ${app.author} under the ${app.license} license.`,app.prefix+"Source: "+app.urls.src],usage:[`
8
- ${app.colors.bw}o Usage:`+app.colors.nc,` ${app.colors.bw}» `+app.colors.bg+app.cmdFormat+app.colors.nc],pathArgs:[`
9
- ${app.colors.bw}o Path arguments:`+app.colors.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 input root (if not provided, css/ is used)."],flags:[`
10
- ${app.colors.bw}o Boolean options:`+app.colors.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."," -r, --relative-output Output files relative to each source file instead of to input root."," -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:[`
11
- ${app.colors.bw}o Parameter options:`+app.colors.nc,'--ignores="dir/,file1.scss,file2.scss" Files/directories to exclude from compilation.',"--comment=\"comment\" Prepend header comment to compiled CSS. Separate by line using '\\n'."],infoCmds:[`
12
- ${app.colors.bw}o Info commands:`+app.colors.nc," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(a=>o[a]?.forEach(o=>{{var i=/header|usage/.test(a)?1:41;let r=process.stdout.columns||80,s=[],e=o.match(/\S+|\s+/g),p="";e.forEach(e=>{var o=r-(s.length?i:0);p.length+"| ".length+e.length>o&&(s.push(s.length?p.trimStart():p),p=""),p+=e}),s.push(s.length?p.trimStart():p),s.forEach((e,o)=>console.info("| "+(0==o?e:" ".repeat(i)+e)))}})),console.info(`
13
- For more help, please visit: `+app.colors.bw+app.urls.docs+app.colors.nc)},helpCmdAndDocURL(){console.info(`
14
- For more help, type 'scss-to-css --help' or visit
15
- `+app.colors.bw+app.urls.docs+app.colors.nc)},ifNotQuiet(e){app.config.quietMode||console.info(e)},version(){var e=require("path"),o=require("child_process").execSync(`npm view ${JSON.stringify(app.name)} version`).toString().trim()||"none";let r,s=process.cwd();for(;"/"!=s;){var p=e.join(s,"package.json");if(require("fs").existsSync(p)){p=require(p);r=(p.dependencies?.[app.name]||p.devDependencies?.[app.name])?.match(/^[~^>=]?\d+\.\d+\.\d+$/)[1]||"none";break}s=e.dirname(s)}console.info(`
16
- Global version: ${o}
17
- Local version: `+r)}};