-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad9a056
commit 8439654
Showing
17 changed files
with
137 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 1.0.0 | ||
|
||
- First stable version | ||
|
||
## 0.0.11 | ||
|
||
- Refactor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* It takes a glob, a write function, and a read function, and then it parses all the files in the glob | ||
* with the write function, and then it writes the result to the file | ||
* @param {string} glob - The glob pattern to match files. | ||
* @param write - (data: string) => Promise<string> = async (data) => data, | ||
* @param read - (file: string) => Promise<string> = async (file) => | ||
*/ | ||
declare const _default: (glob: string, write?: (data: string) => Promise<string>, read?: (file: string) => Promise<string>) => Promise<void>; | ||
export default _default; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Options } from "../options"; | ||
/** | ||
* It takes a settings object, creates a new Critters instance, and then parses all HTML files in the | ||
* given directory, passing each file's contents to the Critters instance | ||
* @param {Options} settings - Options | ||
*/ | ||
declare const _default: (settings: Options) => Promise<void>; | ||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import a from"critters";import p from"./parse";var c=async t=>{const r=new a(t);await p(`${t.path}**/*.html`,async o=>await r.process(o))};export{c as default}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { Options as CritterOptions } from "critters"; | ||
export default interface Options extends CritterOptions { | ||
export interface Options extends CritterOptions { | ||
[key: string]: any; | ||
/** | ||
* Astro build path. | ||
* @default "./dist/" | ||
*/ | ||
path?: string; | ||
} | ||
declare const _default: Options; | ||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var r={path:"./dist/",preload:"swap",inlineFonts:!0,compress:!0};export{r as default}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import fs from "fs"; | ||
import esbuild, { BuildOptions, Plugin } from "esbuild"; | ||
|
||
const outDir = "./dist"; | ||
|
||
const cleanDist: Plugin = { | ||
name: "clean-dist", | ||
setup(build) { | ||
build.onStart(() => { | ||
fs.rm(outDir, { recursive: true }, () => {}); | ||
}); | ||
}, | ||
}; | ||
|
||
const options: BuildOptions = { | ||
entryPoints: [ | ||
"src/index.ts", | ||
"src/lib/parse.ts", | ||
"src/lib/pipe-all.ts", | ||
"src/options/index.ts", | ||
], | ||
format: "esm", | ||
minify: true, | ||
outdir: outDir, | ||
platform: "node", | ||
target: "node14", | ||
write: true, | ||
plugins: [cleanDist], | ||
}; | ||
|
||
await esbuild.build(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import FastGlob from "fast-glob"; | ||
import fs from "fs"; | ||
|
||
/** | ||
* It takes a glob, a write function, and a read function, and then it parses all the files in the glob | ||
* with the write function, and then it writes the result to the file | ||
* @param {string} glob - The glob pattern to match files. | ||
* @param write - (data: string) => Promise<string> = async (data) => data, | ||
* @param read - (file: string) => Promise<string> = async (file) => | ||
*/ | ||
export default async ( | ||
glob: string, | ||
write: (data: string) => Promise<string> = async (data) => data, | ||
read: (file: string) => Promise<string> = async (file) => | ||
await fs.promises.readFile(file, "utf-8") | ||
) => { | ||
const files = await FastGlob(glob); | ||
|
||
for (const file of files) { | ||
try { | ||
const writeBuffer = await write(await read(file)); | ||
|
||
if (!writeBuffer) { | ||
continue; | ||
} | ||
|
||
await fs.promises.writeFile(file, writeBuffer, "utf-8"); | ||
} catch (error) { | ||
console.log("Error: Cannot inline file " + file + " CSS!"); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Critters from "critters"; | ||
|
||
import { Options } from "../options"; | ||
import parse from "./parse"; | ||
|
||
/** | ||
* It takes a settings object, creates a new Critters instance, and then parses all HTML files in the | ||
* given directory, passing each file's contents to the Critters instance | ||
* @param {Options} settings - Options | ||
*/ | ||
export default async (settings: Options) => { | ||
const critters = new Critters(settings); | ||
|
||
await parse( | ||
`${settings.path}**/*.html`, | ||
async (data) => await critters.process(data) | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Options as CritterOptions } from "critters"; | ||
|
||
export interface Options extends CritterOptions { | ||
[key: string]: any; | ||
|
||
/** | ||
* Astro build path. | ||
* @default "./dist/" | ||
*/ | ||
path?: string; | ||
} | ||
|
||
export default { | ||
path: "./dist/", | ||
preload: "swap", | ||
inlineFonts: true, | ||
compress: true, | ||
} as Options; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters