astro-purgecss 4.8.0 → 4.9.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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -213,7 +213,7 @@ Please see the [Changelog](CHANGELOG.md) for more information on what has change
|
|
|
213
213
|
[downloads-badge]: https://img.shields.io/npm/dt/astro-purgecss
|
|
214
214
|
[github-actions]: https://github.com/codiume/orbit/actions
|
|
215
215
|
[github-actions-badge]: https://github.com/codiume/orbit/actions/workflows/node.js.yml/badge.svg
|
|
216
|
-
[typescript]: https://
|
|
216
|
+
[typescript]: https://npmjs.com/package/astro-purgecss
|
|
217
217
|
[typescript-badge]: https://img.shields.io/npm/types/astro-purgecss
|
|
218
218
|
[makepr]: https://makeapullrequest.com
|
|
219
219
|
[makepr-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square?style=flat
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {existsSync}from'node:fs';import {join}from'node:path';import {fileURLToPath}from'node:url';import {PurgeCSS}from'purgecss';import {createHash}from'node:crypto';import {writeFile,unlink
|
|
1
|
+
import {existsSync}from'node:fs';import {join}from'node:path';import {fileURLToPath}from'node:url';import {PurgeCSS}from'purgecss';import {createHash}from'node:crypto';import {readFile,writeFile,unlink}from'node:fs/promises';var b,S,$,O,R=!0;typeof process<"u"&&({FORCE_COLOR:b,NODE_DISABLE_COLORS:S,NO_COLOR:$,TERM:O}=process.env||{},R=process.stdout&&process.stdout.isTTY);var L={enabled:!S&&$==null&&O!=="dumb"&&(b!=null&&b!=="0"||R)};function e(n,t){let s=new RegExp(`\\x1b\\[${t}m`,"g"),g=`\x1B[${n}m`,i=`\x1B[${t}m`;return function(l){return !L.enabled||l==null?l:g+(~(""+l).indexOf(i)?l.replace(s,i+g):l)+i}}var y=e(2,22),E=e(31,39),A=e(32,39);async function P(n){try{return await readFile(n,"utf8")}catch(t){return N(`Error reading file ${n}: ${t}`),""}}async function F(n,t){try{await writeFile(n,t,"utf8");}catch(s){return N(`Error writing file ${n}: ${s}`),""}}async function x(n,t,s){await F(n,t),existsSync(s)&&s!==n&&await unlink(s);}function T(n,t){let s=createHash("sha256").update(t).digest("hex").slice(0,8);return `${n.slice(0,-13)}.${s}.css`}var D=new Intl.DateTimeFormat("en-us",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function d(n){let t=D.format(new Date);console.log(y(t),A("\u25B6"),n);}function N(n){let t=D.format(new Date);console.error(y(t),E("\u25A0"),n);}var v="astro-purgecss",G=n=>n.match(/[\w-/:]+(?<!:)/g)||[];function W(n={}){let t;return {name:v,hooks:{"astro:config:done":({config:s})=>{t=s;},"astro:build:done":async({dir:s,pages:g,logger:i})=>{let l=t.output;i.info(`\u{1F4E6} Running in '${l}' mode`);let o=fileURLToPath(s),I=l!=="static";if(!o||!t.build.format||!t.build.assets){i.warn(`${v} requires the following astro.config options: 'outDir', 'build.format', 'build.assets'`);return}let f=(await new PurgeCSS().purge({css:[join(o,"/**/*.css")],defaultExtractor:G,...n,content:[join(o,"/**/*.html"),join(o,"/**/*.js"),...n.content||[]]})).filter(({file:c})=>c?.endsWith(".css"));if(f.length===0){i.info("\u2139\uFE0F No CSS files found to process");return}if(i.info(`Found ${f.length} CSS ${f.length===1?"file":"files"} to process`),I){await Promise.all(f.map(async({css:c,file:r})=>{await x(r,c,r),d(r.replace(o,""));})),i.info("\u{1F389} Purging completed successfully!");return}let m=(await Promise.all(f.map(async({css:c,file:r})=>{if(!r.includes(t.build.assets)){await x(r,c,r);let w=r.replace(o,"");return d(w),{oldFilename:w,newFilename:w}}let p=T(r,c);await x(p,c,r);let h=r.replace(o,""),C=p.replace(o,"");return d(C),{oldFilename:h,newFilename:C}}))).filter(({oldFilename:c,newFilename:r})=>c!==r);if(m.length>0){i.info(`Updating ${m.length} CSS ${m.length===1?"reference":"references"} in HTML files...`);let c=g.filter(r=>typeof r.pathname=="string").map(r=>{let a=r.pathname;if(a==="")return join(o,"index.html");switch(t.build.format){case"file":return join(o,`${a}.html`);case"directory":return join(o,a,"index.html");case"preserve":let p=join(o,`${a}.html`);return existsSync(p)?p:join(o,a,"index.html")}});await Promise.all(c.map(async r=>{let a=await P(r);for(let{oldFilename:p,newFilename:h}of m)a.includes(p)&&(a=a.replace(new RegExp(p,"g"),h));await F(r,a),d(r.replace(o,""));}));}i.info("\u{1F389} Purging completed successfully!");}}}}var Ae=W;export{Ae as default};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-purgecss",
|
|
3
3
|
"description": "Remove unused CSS rules from your final Astro bundle",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.9.0",
|
|
5
5
|
"homepage": "https://github.com/codiume/orbit",
|
|
6
6
|
"bugs": "https://github.com/codiume/orbit/issues",
|
|
7
7
|
"author": "codiume",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"astro": "^4.0.0",
|
|
42
|
-
"purgecss": "^
|
|
42
|
+
"purgecss": "^7.0.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsup",
|