Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed May 9, 2022
1 parent d0c522d commit 8be8b92
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.2

- Refactor

## 0.0.1

- Initial version
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function createPlugin(integrationOptions = {}) {
hooks: {
"astro:build:done": async ({ pages }) => {
const files = {
css: FastGlob.sync(`${options.path}**/*.css`),
html: pages.map((page) => {
css: !options.css ? [] : FastGlob.sync(`${options.path}**/*.css`),
html: !options.html ? [] : pages.map((page) => {
const pathname = page.pathname.endsWith("/") ? page.pathname : `${page.pathname}/`;
const file = pathname === "404/" ? "404.html" : `${pathname}index.html`;
return `${options.path}${file}`;
Expand Down
12 changes: 6 additions & 6 deletions dist/options.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { CSS } from "./options/csso";
import { HTML } from "./options/html-minifier";
import CSS from "./options/csso";
import HTML from "./options/html-minifier";
export default interface Options {
/**
* Astro build path.
* Default: "./dist/"
*/
path?: string;
/**
* csso options.
* [csso] options.
*/
css?: CSS;
css?: CSS | false;
/**
* html-minifier options.
* [html-minifier-terser] options.
*/
html?: HTML;
html?: HTML | false;
}
2 changes: 1 addition & 1 deletion dist/options/csso.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface afterCompressOptions {
compressResult?: String;
options?: {};
}
export interface CSS {
export default interface CSS {
/**
* Generate a source map when true.
* Default: false
Expand Down
2 changes: 1 addition & 1 deletion dist/options/html-minifier.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface HTML {
export default interface HTML {
/**
* Treat attributes in case sensitive manner (useful for custom HTML tags).
* Default: false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro-compress",
"version": "0.0.1",
"version": "0.0.2",
"type": "module",
"description": "AstroJS compression utilities. Compress HTML, CSS, JavaScript and more.",
"repository": {
Expand Down
26 changes: 15 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,23 @@ export default function createPlugin(
hooks: {
"astro:build:done": async ({ pages }) => {
const files: Files = {
css: FastGlob.sync(`${options.path}**/*.css`),
html: pages.map((page) => {
const pathname = page.pathname.endsWith("/")
? page.pathname
: `${page.pathname}/`;
css: !options.css
? []
: FastGlob.sync(`${options.path}**/*.css`),
html: !options.html
? []
: pages.map((page) => {
const pathname = page.pathname.endsWith("/")
? page.pathname
: `${page.pathname}/`;

const file =
pathname === "404/"
? "404.html"
: `${pathname}index.html`;
const file =
pathname === "404/"
? "404.html"
: `${pathname}index.html`;

return `${options.path}${file}`;
}),
return `${options.path}${file}`;
}),
};

for (const type in files) {
Expand Down
12 changes: 6 additions & 6 deletions src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSS } from "./options/csso";
import { HTML } from "./options/html-minifier";
import CSS from "./options/csso";
import HTML from "./options/html-minifier";

export default interface Options {
/**
Expand All @@ -9,12 +9,12 @@ export default interface Options {
path?: string;

/**
* csso options.
* [csso] options.
*/
css?: CSS;
css?: CSS | false;

/**
* html-minifier options.
* [html-minifier-terser] options.
*/
html?: HTML;
html?: HTML | false;
}
2 changes: 1 addition & 1 deletion src/options/csso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface afterCompressOptions {
options?: {};
}

export interface CSS {
export default interface CSS {
/**
* Generate a source map when true.
* Default: false
Expand Down
2 changes: 1 addition & 1 deletion src/options/html-minifier.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface HTML {
export default interface HTML {
/**
* Treat attributes in case sensitive manner (useful for custom HTML tags).
* Default: false
Expand Down

0 comments on commit 8be8b92

Please sign in to comment.