@adamlui/scss-to-css 2.0.1 → 2.2.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
@@ -27,14 +27,14 @@
27
27
 
28
28
  # { } scss-to-css
29
29
 
30
- ### Recursively compile all SCSS files into minified CSS.
30
+ ### Recursively compile all SCSS files into minified CSS
31
31
 
32
32
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css">
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.2.0">
37
+ <img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.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">
@@ -158,16 +158,45 @@ Boolean options:
158
158
  -q, --quiet Suppress all logging except errors.
159
159
 
160
160
  Parameter options:
161
- --ignores="dir/,file1.scss,file2.scss" Files/directories to exclude from
161
+ --ignores="dir/,file1.scss,file2.sass" Files/directories to exclude from
162
162
  compilation.
163
163
  --comment="comment" Prepend header comment to
164
164
  compiled CSS. Separate by
165
165
  line using '\n'.
166
- Info commands:
166
+ --ui-lang="code" ISO 639-1 code of language to display UI in.
167
+ --config="path/to/file" Load custom config file.
168
+
169
+ Commands:
170
+ -i, --init Create config file (in project root).
167
171
  -h, --help Display help screen.
168
172
  -v, --version Show version number.
169
173
  ```
170
174
 
175
+ #
176
+
177
+ ### Configuration file
178
+
179
+ **scss-to-css** can be customized using a `scss-to-css.config.mjs` or `scss-to-css.config.js` placed in your project root.
180
+
181
+ Example defaults:
182
+
183
+ ```js
184
+ export default {
185
+ dryRun: false, // don't actually minify the file(s), just show if they will be processed
186
+ includeDotFolders: false, // include dotfolders in file search
187
+ noSourceMaps: false, // prevent source maps from being generated
188
+ noMinify: false, // disable minification of output CSS
189
+ noRecursion: false, // disable recursive file searching
190
+ relativeOutput: false, // output files relative to each src file instead of to input root
191
+ copy: false, // copy compiled CSS to clipboard instead of write to file if single file processed
192
+ quietMode: false, // suppress all logging except errors
193
+ ignores: '', // files/dirs to exclude from minification
194
+ comment: '' // header comment to prepend to minified code
195
+ }
196
+ ```
197
+
198
+ 💡 Run `scss-to-css init` to generate a template `scss-to-css.config.mjs` in your project root.
199
+
171
200
  <br>
172
201
 
173
202
  <img height=6px width="100%" src="https://assets.scsstocss.org/images/separators/aqua-gradient.png?v=7e4a141">
@@ -179,7 +208,7 @@ You can also import **scss-to-css** into your app to use its API methods, both a
179
208
  #### ECMAScript*:
180
209
 
181
210
  ```js
182
- import scssToCSS from '@adamlui/scss-to-css';
211
+ import scssToCSS from '@adamlui/scss-to-css'
183
212
  ```
184
213
 
185
214
  #### CJS:
@@ -259,7 +288,7 @@ findSCSS() » Search complete! 2 files found.
259
288
  findSCSS() » Check returned array.
260
289
  [
261
290
  'E:\\js\\utils\\scss-to-css\assets\\scss\\foo.scss',
262
- 'E:\\js\\utils\\scss-to-css\assets\\scss\\bar.scss'
291
+ 'E:\\js\\utils\\scss-to-css\assets\\scss\\bar.sass'
263
292
  ]
264
293
  */
265
294
  ```
@@ -1,21 +1,9 @@
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()=>{globalThis.env={args:process.argv.slice(2),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)},env.debugMode=env.args.some(e=>/^--?debug(?:-?mode)?$/.test(e));let e=require(`./lib/compile${env.devMode?"":".min"}.js`),s=require(`../scss-to-css${env.devMode?"":".min"}.js`).findSCSS,i=require("fs"),o=require(`./lib/language${env.devMode?"":".min"}.js`),r=require(`./lib/log${env.devMode?"":".min"}.js`),c=require("path"),n=require(`./lib/settings${env.devMode?"":".min"}.js`);Object.assign(globalThis.cli??={},require(`../${env.devMode?"../":"data/"}package-data.json`)),n.load("uiLang"),env.sysLang=cli.config.uiLang||(env.debugMode?o.generateRandomLang({excludes:["en"]}):o.getSysLang()),cli.msgs=await o.getMsgs(env.sysLang),cli.urls.docs+="/#-command-line-usage",env.sysLang.startsWith("en")||(cli.docLocale=env.sysLang.replace("_","-").toLowerCase(),cli.docLocales=await o.getDocLocales(),cli.docLocales.includes(cli.docLocale)&&(cli.urls.docs=cli.urls.docs.replace(/\/[^/]+$/g,`/${cli.docLocale}#readme`)));for(var l of env.args){if(n.controls.init.regex.test(l))return n.initConfigFile();if(n.controls.help.regex.test(l))return r.help();if(n.controls.version.regex.test(l))return r.version()}var[t="",a=""]=env.args.filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,""));let g=c.resolve(process.cwd(),t);t&&!i.existsSync(g)&&(d=g+".scss",i.existsSync(d)?g=d:(r.error(`${cli.msgs.error_firstArgNotExist}.\n${g} ${cli.msgs.error_doesNotExist}.`),r.success(cli.msgs.info_exampleValidCmd+`:
8
+ » scss-to-css . output.min.css`),r.helpCmdAndDocURL(),process.exit(1))),n.load();var d=/s[ac]ss$/.test(g)&&!i.statSync(g).isDirectory()?[g]:s(g,{recursive:!cli.config.noRecursion,verbose:!cli.config.quietMode,ignores:(cli.config.ignores?.split(",")??[]).map(e=>e.trim())});cli.config.dryRun?d.length?(r.info(cli.msgs.info_scssFilesToBeCompiled+":"),d.forEach(e=>console.info(r.colors.gry,e,r.colors.nc))):r.info(`
9
+ ${cli.msgs.info_noSCSSfilesWillBeCompiled}.`):e.scss({srcFiles:d,inputPath:g,inputArg:t,outputArg:a})})();
@@ -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 log=require(`./log${env.devMode?"":".min"}.js`);module.exports={scss({srcFiles:i,inputPath:e,inputArg:r,outputArg:t}){let o=require(`../../scss-to-css${env.devMode?"":".min"}.js`).compile,g=require("fs"),a=require("path"),c=[],s=[];var n;!cli.config.relativeOutput&&g.statSync(e).isDirectory()?(n=o(e,{verbose:!1,minify:!cli.config.noMinify,comment:cli.config.comment?.replace(/\\n/g,"\n"),relativeOutput:!1,recursive:!cli.config.noRecursion,dotFolders:cli.config.includeDotFolders,sourceMaps:!cli.config.noSourceMaps,ignores:cli.config.ignores?cli.config.ignores.split(",").map(i=>i.trim()):[]}))&&(n.error?c.push(e):s=[].concat(n)):s=i.map(i=>{var e=o(i,{verbose:!cli.config.quietMode,minify:!cli.config.noMinify,sourceMaps:!cli.config.noSourceMaps,comment:cli.config.comment?.replace(/\\n/g,"\n")});return e.error&&c.push(i),e}).filter(i=>!i.error),cli.config.quietMode||(n=1==(e=s.length)?"":"s",e?(log.success(cli.msgs.info_compilationComplete+"!"),log.data(`${e} CSS ${cli.msgs.info_file}${n}${cli.config.noSourceMaps?"":` + ${e} `+cli.msgs.info_srcMap+n} ${cli.msgs.info_generated}.`)):console.info(cli.msgs.info_noSCSSfilesProcessed+"."),c.length&&(log.error(c.length+" "+cli.msgs.info_file+(1==c.length?"":"s"),cli.msgs.info_failedToCompile+":"),c.forEach(i=>log.ifNotQuiet(i)))),s?.length&&(cli.config.copy&&1==s?.length?(log.data(s[0].code),log.ifNotQuiet(`
7
+ ${cli.msgs.info_copyingToClip}...`),require("node-clipboardy").writeSync(s[0].code)):(log.ifNotQuiet(`
8
+ ${cli.msgs.info_writing}${1<s?.length?"s":""}...`),s?.forEach(({code:i,srcMap:e,srcPath:o,relPath:c})=>{let s,n;if(!cli.config.relativeOutput&&c){let i=a.resolve(process.cwd(),t||"css"),e=a.dirname(c);s="."!=e?a.join(i,e):i,n=`${a.basename(o,a.extname(o))}${cli.config.noMinify?"":".min"}.css`}else s=a.join(a.dirname(o),t.endsWith(".css")?a.dirname(t):t||"css"),n=`${t.endsWith(".css")&&/s[ac]ss$/.test(r)?a.basename(t).replace(/(\.min)?\.css$/,""):a.basename(o,a.extname(o))}.min.css`;let l=a.join(s,n);g.mkdirSync(s,{recursive:!0}),g.writeFileSync(l,i,"utf8"),log.ifNotQuiet(` ${log.colors.bg}✓${log.colors.nc} `+a.relative(process.cwd(),l)),cli.config.noSourceMaps||g.writeFileSync(l+".map",JSON.stringify(e),"utf8"),log.ifNotQuiet(` ${log.colors.bg}✓${log.colors.nc} ${a.relative(process.cwd(),l)}.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("fs"),a=require("path"),a=a.join(a.dirname(e),`.${a.basename(e)}.tmp`);n.writeFileSync(a,r,t),n.renameSync(a,e)},fetch(n){return"undefined"==typeof fetch?new Promise((t,e)=>{var r=n.match(/^([^:]+):\/\//)[1];/^https?$/.test(r)||e(new Error(cli.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,7 @@
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`),log=require(`./log${env.devMode?"":".min"}.js`);module.exports={formatCode(e){return e.replace(/([a-z]{2,8})[-_]([a-z]{2})/i,(e,r,a)=>r.toLowerCase()+"_"+a.toUpperCase())},generateRandomLang({includes:e=[],excludes:r=[]}={}){let t=require("fs"),s=require("path"),a=e.length?e:(()=>{var e=s.join(__dirname,"..",".cache"),r=s.join(e,"locales.json");if(t.existsSync(r))try{return JSON.parse(t.readFileSync(r,"utf8"))}catch(e){}var a=s.resolve(process.cwd(),"_locales");return t.existsSync(a)?(a=t.readdirSync(a,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).filter(e=>/^\w{2}[-_]?\w{0,2}$/.test(e)),t.mkdirSync(e,{recursive:!0}),data.atomicWrite(r,JSON.stringify(a,null,2)),a):["en"]})(),n=new Set(r),l="en";return(a=a.filter(e=>!n.has(e))).length&&(l=a[Math.floor(Math.random()*a.length)]),log.debug(`Random language: ${l}
7
+ `),l},async getDocLocales(){cli.version??=require(`./pkg${env.devMode?"":".min"}.js`).getVer("local");var e=cli.version?"v"+cli.version:"latest",e=cli.urls.jsdelivr+`@${e}/docs/`,r=[];try{for(var a,t=await(await data.fetch(e)).text(),s=/href=".*\/docs\/([^/]+)\/"/g;a=s.exec(t);)r.push(a[1])}catch(e){log.warn(cli.msgs.warn_docLocalesFetchFailed+":",e.message)}return r},async getMsgs(t="en"){t=module.exports.formatCode(t);let e=data.flatten(require(`../../${env.devMode?"../_locales/en/":"data/"}messages.json`));if(!t.startsWith("en")){var s=`${cli.urls.jsdelivr}@${cli.commitHashes.locales}/_locales/`;let r=s+t+"/messages.json",a=0;for(;a<3;)try{e=data.flatten(await(await data.fetch(r)).json());break}catch(e){if(3<=++a)break;log.debug(r=t.includes("-")&&1==a?r.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):s+"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 log.error("ERROR loading system language:",e.message),"en"}}};
@@ -0,0 +1,22 @@
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:"",gry:"",blk:"",tlBG:""},configURL(){this.info(`
7
+ ${cli.msgs.info_exampleValidConfigFile}: `+cli.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}${cli.msgs.prefix_error}:`,...s,this.colors.nc)},errorAndExit(...s){this.error(...s),this.helpCmdAndDocURL(),process.exit(1)},ifNotQuiet(s){cli.config.quietMode||console.info(s)},info(s){console.info(`
10
+ `+this.colors.by+s+this.colors.nc)},tip(s){console.info(""+this.colors.by+cli.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}${cli.msgs.prefix_warning}:`,...s,this.colors.nc)},help(s=["header","usage","pathArgs","flags","params","cmds"]){cli.prefix=""+this.colors.tlBG+this.colors.blk+` ${cli.name.replace(/^@[^/]+\//,"")} ${this.colors.nc} `;let o={header:[`
13
+ ├ ${cli.prefix}${cli.msgs.appCopyright}.`,""+cli.prefix+cli.msgs.prefix_source+": "+cli.urls.src],usage:[`
14
+ ${this.colors.bw}o ${cli.msgs.helpSection_usage}:`+this.colors.nc,` ${this.colors.bw}» `+this.colors.bg+cli.cmdFormat+this.colors.nc],pathArgs:[`
15
+ ${this.colors.bw}o ${cli.msgs.helpSection_pathArgs}:`+this.colors.nc,` [inputPath] ${cli.msgs.inputPathDesc_main}, ${cli.msgs.inputPathDesc_extra}.`,` [outputPath] ${cli.msgs.outputPathDesc_main}, `+cli.msgs.outputPathDesc_extra],flags:[`
16
+ ${this.colors.bw}o ${cli.msgs.helpSection_flags}:`+this.colors.nc,` -n, --dry-run ${cli.msgs.optionDesc_dryRun}.`,` -d, --include-dotfolders ${cli.msgs.optionDesc_dotfolders}.`,` -S, --no-source-maps ${cli.msgs.optionDesc_noSourceMaps}.`,` -M, --no-minify ${cli.msgs.optionDesc_noMinify}.`,` -R, --no-recursion ${cli.msgs.optionDesc_noRecursion}.`,` -r, --relative-output ${cli.msgs.optionDesc_relativeOutput}.`,` -c, --copy ${cli.msgs.optionDesc_copy}.`,` -q, --quiet ${cli.msgs.optionDesc_quiet}.`],params:[`
17
+ ${this.colors.bw}o ${cli.msgs.helpSection_params}:`+this.colors.nc,`--ignores="dir/,file1.scss,file2.sass" ${cli.msgs.optionDesc_ignores}.`,`--comment="comment" ${cli.msgs.optionDesc_commentMain}. ${cli.msgs.optionDesc_commentExtra}.`,` --ui-lang="code" ${cli.msgs.optionDesc_uiLang}.`,` --config="path/to/file" ${cli.msgs.optionDesc_config}.`],cmds:[`
18
+ ${this.colors.bw}o ${cli.msgs.helpSection_cmds}:`+this.colors.nc,` -i, --init ${cli.msgs.optionDesc_init}.`,` -h, --help ${cli.msgs.optionDesc_help}.`,` -v, --version ${cli.msgs.optionDesc_version}.`]};s.forEach(t=>o[t]?.forEach(o=>{{var e=/header|usage/.test(t)?1:41;let i=process.stdout.columns||80,s=o.match(/\S+|\s+/g),c=[],l="";s.forEach(s=>{var o=i-(c.length?e:0);l.length+"| ".length+s.length>o&&(c.push(c.length?l.trimStart():l),l=""),l+=s}),c.push(c.length?l.trimStart():l),c.forEach((s,o)=>console.info("| "+(0==o?s:" ".repeat(e)+s)))}})),console.info(`
19
+ ${cli.msgs.info_moreHelp}, ${cli.msgs.info_visit}: `+this.colors.bw+cli.urls.docs+this.colors.nc)},helpCmdAndDocURL(){console.info(`
20
+ ${cli.msgs.info_moreHelp}, ${cli.msgs.info_type} ${cli.name.split("/")[1]} --help' ${cli.msgs.info_or} ${cli.msgs.info_visit}
21
+ `+this.colors.bw+cli.urls.docs+this.colors.nc)},version(){var s=require(`./pkg${env.devMode?"":".min"}.js`).getVer;this.info(""+cli.name),this.data(`${cli.msgs.prefix_globalVer}: ${s("global")||"none"}
22
+ ${cli.msgs.prefix_localVer}: `+(s("local")||"none"))}};
@@ -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
+ let log=require(`./log${env.devMode?"":".min"}.js`);module.exports={getVer(e="any"){let r;if("global"!=e)try{var l=require("path").resolve(process.cwd(),"node_modules",cli.name,"package.json");r=require(l).version}catch(e){log.debug(cli.msgs.error_readingLocalPkgVer+": "+e.message)}if("global"==e||"all"==e&&!r)try{r=require("child_process").execSync(`npm view ${JSON.stringify(cli.name)} version`).toString().trim()}catch(e){log.debug(cli.msgs.error_failedToFetchGlobalVer+": "+e.message)}return r}};
@@ -0,0 +1,7 @@
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.cli??={}).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:"flag",regex:/^--?(?:r|relative-?output?=?(?:true|1)?)$/},copy:{type:"flag",regex:/^--?c(?:opy)?$/},quietMode:{type:"flag",regex:/^--?q(?:uiet)?(?:-?mode)?$/},ignores:{type:"param",regex:/^--?(?:ignores?|(?:ignore|skip|exclude)(?:d?-?files?)?)(?:=.*|$)/},comment:{type:"param",regex:/^--?comments?(?:=.*|$)/},uiLang:{type:"param",regex:/^--?ui-?lang(?:=.*|$)/},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 i={target:path.resolve(process.cwd(),e)};if(fs.existsSync(i.target))return log.warn(cli.msgs.warn_configFileExists+":",i.target);if(fs.existsSync(i.src=path.resolve(__dirname,"../../"+(env.devMode?"../":"data/")+e)))fs.copyFileSync(i.src,i.target);else{cli.version??=require(`./pkg${env.devMode?"":".min"}.js`).getVer("local");var t=require(`./data${env.devMode?"":".min"}.js`),r=cli.version?"v"+cli.version:"latest",r=cli.urls.jsdelivr+`@${r}/`+e;log.data(cli.msgs.info_fetchingRemoteConfigFrom+` ${r}...`);try{var o=await t.fetch(r);if(!o.ok)return log.warn(`${cli.msgs.warn_remoteConfigNotFound}: ${r} (${o.status})`);t.atomicWrite(i.target,await o.text())}catch(e){return log.warn(cli.msgs.warn_remoteConfigFailed+`: ${r} `+e.message)}}log.success(`${cli.msgs.info_configFileCreated}: ${i.target}\n`),log.tip(cli.msgs.tip_editToSetDefaults+"."),log.tip(cli.msgs.tip_cliArgsPrioritized+".")},load(e=Object.keys(this.controls)){let o=[].concat(e);if(arguments.length||cli.defaultsSet||(o.forEach(e=>{var i=this.controls[e];i.mode||"cmd"==i.type||(cli.config[e]??=i.defaultVal??("flag"!=i.type&&""))}),cli.defaultsSet=!0),!cli.configPathTried){e=env.args.find(e=>this.controls.config.regex.test(e));if(e){/=/.test(e)||log.errorAndExit(`[${e}] `+cli.msgs.error_mustIncludePath);e=e.split("=")[1];cli.configPath=path.isAbsolute(e)?e:path.resolve(process.cwd(),e),fs.existsSync(cli.configPath)||log.configURLandExit(cli.msgs.error_configFileNotFound+":",cli.configPath)}else for(var i of["mjs","cjs","js"]){i=path.resolve(process.cwd(),this.configFilename.replace(/\.[^.]+$/,"."+i));if(fs.existsSync(i)){cli.configPath=i;break}}cli.configPathTried=!0}if(cli.configPath)try{let e=require(cli.configPath),t=e?.default??e;t&&"object"==typeof t||log.configURLandExit(cli.msgs.error_invalidConfigFile+"."),Object.assign(cli.config,arguments.length?o.reduce((e,i)=>t[i]?{...e,[i]:t[i]}:e,{}):t)}catch(e){log.configURLandExit(cli.msgs.error_failedToLoadConfigFile+":",cli.configPath,`
7
+ `+e.message)}return env.args.forEach(i=>{if(!/^[^-]|--?(?:config|debug)/.test(i)){var t=Object.keys(this.controls).find(e=>this.controls[e]?.regex?.test(i));if(t||arguments.length||log.errorAndExit(`[${i}] ${cli.msgs.error_notRecognized}.`),o.includes(t)){var r=this.controls[t];if("cmd"!=r.type){let e="param"!=r.type||i.split("=")[1]?.trim();r.mode?cli.config.mode=t.replace(/mode$/i,"").toLowerCase():((r=r.parser)&&(e=r(e),isNaN(e)||e<1)&&log.errorAndExit(`[${t}] ${cli.msgs.error_nonPositiveNum}.`),cli.config[t]=e)}}}}),cli.config}};
@@ -0,0 +1,70 @@
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_readingLocalPkgVer": { "message": "Error reading local package version" },
11
+ "error_notRecognized": { "message": "not recognized" },
12
+ "error_nonPositiveNum": { "message": "argument can only be > 0" },
13
+ "error_invalidURL": { "message": "Invalid URL" },
14
+ "error_invalidConfigFile": { "message": "Config file must export an object" },
15
+ "error_configFileNotFound": { "message": "Config file not found" },
16
+ "error_failedToLoadConfigFile": { "message": "Failed to load config file" },
17
+ "error_failedToFetchGlobalVer": { "message": "Failed to fetch global version" },
18
+ "error_mustIncludePath": { "message": "must include =path" },
19
+ "warn_configFileExists": { "message": "Config file already exists" },
20
+ "info_exampleValidConfigFile": { "message": "Example valid config file" },
21
+ "error_firstArgNotExist": { "message": "First argument can only be an existing file or directory" },
22
+ "error_doesNotExist": { "message": "does not exist" },
23
+ "info_exampleValidCmd": { "message": "Example valid command" },
24
+ "info_scssFilesToBeCompiled": { "message": "SCSS files to be compiled" },
25
+ "info_noSCSSfilesWillBeCompiled": { "message": "No SCSS files will be compiled" },
26
+ "info_copyingToClip": { "message": "Copying to clipboard" },
27
+ "info_writing": { "message": "Writing to file" },
28
+ "info_compilationComplete": { "message": "Compilation complete" },
29
+ "info_file": { "message": "file" },
30
+ "info_srcMap": { "message": "source map" },
31
+ "info_generated": { "message": "generated" },
32
+ "info_noSCSSfilesProcessed": { "message": "No SCSS files processed" },
33
+ "info_failedToCompile": { "message": "failed to compile" },
34
+ "info_moreHelp": { "message": "For more help" },
35
+ "info_type": { "message": "type" },
36
+ "info_or": { "message": "or" },
37
+ "info_visit": { "message": "visit" },
38
+ "info_configFileCreated": { "message": "Config file created" },
39
+ "info_fetchingRemoteConfigFrom": { "message": "Fetching remote config file from" },
40
+ "warn_remoteConfigNotFound": { "message": "Remote config file not found" },
41
+ "warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
42
+ "warn_docLocalesFetchFailed": { "message": "Failed to fetch doc locales" },
43
+ "tip_editToSetDefaults": { "message": "Edit this file to customize defaults" },
44
+ "tip_cliArgsPrioritized": { "message": "CLI arguments always override these values" },
45
+ "helpSection_usage": { "message": "Usage" },
46
+ "helpSection_pathArgs": { "message": "Path arguments" },
47
+ "helpSection_flags": { "message": "Boolean options" },
48
+ "helpSection_params": { "message": "Parameter options" },
49
+ "helpSection_cmds": { "message": "Commands" },
50
+ "optionDesc_uiLang": { "message": "ISO 639-1 code of language to display UI in" },
51
+ "inputPathDesc_main": { "message": "Path to SCSS file or directory containing SCSS files to be compiled" },
52
+ "inputPathDesc_extra": { "message": "relative to the current working directory" },
53
+ "outputPathDesc_main": { "message": "Path to file or directory where CSS + sourcemap files will be stored" },
54
+ "outputPathDesc_extra": { "message": "relative to input root (if not provided, css/ is used)" },
55
+ "optionDesc_dryRun": { "message": "Don't actually compile the file(s), just show if they will be processed" },
56
+ "optionDesc_dotfolders": { "message": "Include dotfolders in file search" },
57
+ "optionDesc_noSourceMaps": { "message": "Prevent source maps from being generated" },
58
+ "optionDesc_noMinify": { "message": "Disable minification of output CSS" },
59
+ "optionDesc_noRecursion": { "message": "Disable recursive file searching" },
60
+ "optionDesc_copy": { "message": "Copy compiled CSS to clipboard instead of writing to file if single source file is processed" },
61
+ "optionDesc_relativeOutput": { "message": "Output files relative to each source file instead of to input root" },
62
+ "optionDesc_quiet": { "message": "Suppress all logging except errors" },
63
+ "optionDesc_ignores": { "message": "Files/directories to exclude from compilation" },
64
+ "optionDesc_commentMain": { "message": "Prepend header comment to compiled CSS" },
65
+ "optionDesc_commentExtra": { "message": "Separate by line using '\\n'" },
66
+ "optionDesc_config": { "message": "Load custom config file" },
67
+ "optionDesc_init": { "message": "Create config file (in project root)" },
68
+ "optionDesc_help": { "message": "Display help screen" },
69
+ "optionDesc_version": { "message": "Show version number" }
70
+ }
@@ -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": "69b01f2"
13
17
  }
14
18
  }
@@ -0,0 +1,29 @@
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
+ // Info options
14
+ dryRun: false, // don't actually minify the file(s), just show if they will be processed
15
+ quietMode: false, // suppress all logging except errors
16
+ uiLang: '', // ISO 639-1 code of language to display UI in
17
+
18
+ // Input options
19
+ includeDotFolders: false, // include dotfolders in file search
20
+ noRecursion: false, // disable recursive file searching
21
+ ignores: '', // files/dirs to exclude from minification
22
+
23
+ // Output options
24
+ noSourceMaps: false, // prevent source maps from being generated
25
+ noMinify: false, // disable minification of output CSS
26
+ relativeOutput: false, // output files relative to each src file instead of to input root
27
+ copy: false, // copy compiled CSS to clipboard instead of write to file if single file processed
28
+ comment: '' // header comment to prepend to minified code
29
+ }
@@ -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 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})):/s[ac]ss$/.test(e)&&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(!/s[ac]ss$/.test(i)||!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.api??={},require(`${/[\\/]src(?:[\\/]|$)/i.test(__dirname)?"../":"./data/"}package-data.json`)),api.aliases={compile:["build","Build","Compile","compress","Compress","minify","Minify"],findSCSS:["find","Find","findscss","findScss","Findscss","FindScss","FindSCSS","search","Search"]};let log={prefix:api.name,error(...e){console.error(this.prefix+" » ERROR:",...e)},helpURL(e=api.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,null,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 api.aliases)api.aliases[s].forEach(e=>module.exports[e]??=module.exports[s]);
package/docs/README.md CHANGED
@@ -27,14 +27,14 @@
27
27
 
28
28
  # { } scss-to-css
29
29
 
30
- ### Recursively compile all SCSS files into minified CSS.
30
+ ### Recursively compile all SCSS files into minified CSS
31
31
 
32
32
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css">
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.2.0">
37
+ <img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.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">
@@ -158,16 +158,45 @@ Boolean options:
158
158
  -q, --quiet Suppress all logging except errors.
159
159
 
160
160
  Parameter options:
161
- --ignores="dir/,file1.scss,file2.scss" Files/directories to exclude from
161
+ --ignores="dir/,file1.scss,file2.sass" Files/directories to exclude from
162
162
  compilation.
163
163
  --comment="comment" Prepend header comment to
164
164
  compiled CSS. Separate by
165
165
  line using '\n'.
166
- Info commands:
166
+ --ui-lang="code" ISO 639-1 code of language to display UI in.
167
+ --config="path/to/file" Load custom config file.
168
+
169
+ Commands:
170
+ -i, --init Create config file (in project root).
167
171
  -h, --help Display help screen.
168
172
  -v, --version Show version number.
169
173
  ```
170
174
 
175
+ #
176
+
177
+ ### Configuration file
178
+
179
+ **scss-to-css** can be customized using a `scss-to-css.config.mjs` or `scss-to-css.config.js` placed in your project root.
180
+
181
+ Example defaults:
182
+
183
+ ```js
184
+ export default {
185
+ dryRun: false, // don't actually minify the file(s), just show if they will be processed
186
+ includeDotFolders: false, // include dotfolders in file search
187
+ noSourceMaps: false, // prevent source maps from being generated
188
+ noMinify: false, // disable minification of output CSS
189
+ noRecursion: false, // disable recursive file searching
190
+ relativeOutput: false, // output files relative to each src file instead of to input root
191
+ copy: false, // copy compiled CSS to clipboard instead of write to file if single file processed
192
+ quietMode: false, // suppress all logging except errors
193
+ ignores: '', // files/dirs to exclude from minification
194
+ comment: '' // header comment to prepend to minified code
195
+ }
196
+ ```
197
+
198
+ 💡 Run `scss-to-css init` to generate a template `scss-to-css.config.mjs` in your project root.
199
+
171
200
  <br>
172
201
 
173
202
  <img height=6px width="100%" src="https://assets.scsstocss.org/images/separators/aqua-gradient.png?v=7e4a141">
@@ -179,7 +208,7 @@ You can also import **scss-to-css** into your app to use its API methods, both a
179
208
  #### ECMAScript*:
180
209
 
181
210
  ```js
182
- import scssToCSS from '@adamlui/scss-to-css';
211
+ import scssToCSS from '@adamlui/scss-to-css'
183
212
  ```
184
213
 
185
214
  #### CJS:
@@ -259,7 +288,7 @@ findSCSS() » Search complete! 2 files found.
259
288
  findSCSS() » Check returned array.
260
289
  [
261
290
  'E:\\js\\utils\\scss-to-css\assets\\scss\\foo.scss',
262
- 'E:\\js\\utils\\scss-to-css\assets\\scss\\bar.scss'
291
+ 'E:\\js\\utils\\scss-to-css\assets\\scss\\bar.sass'
263
292
  ]
264
293
  */
265
294
  ```
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.2.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.1",
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)}};