-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
36 lines (34 loc) · 1.21 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Plugin, KeyedStoreTrigger, Step } from "@shanzhai/interfaces";
import { MinifyHtmlStep } from "@shanzhai/minify-html-step";
import { htmlSourceStore } from "@shanzhai/html-source-store";
import { zipContentStore } from "@shanzhai/zip-content-store";
import { DeleteFromKeyedStoreStep } from "@shanzhai/delete-from-keyed-store-step";
import { KeyedStoreGetInput } from "@shanzhai/keyed-store-get-input";
import { KeyedStoreSetOutput } from "@shanzhai/keyed-store-set-output";
import { WrapInObjectOutput } from "@shanzhai/wrap-in-object-output";
const minifyHtmlPlugin: Plugin<{
readonly minifyHtml: KeyedStoreTrigger;
}> = {
triggers: {
minifyHtml: {
type: `keyedStore`,
keyedStore: htmlSourceStore,
refreshAllWhenStoresChange: [],
down(key: string): Step {
return new DeleteFromKeyedStoreStep(zipContentStore, key);
},
up(key: string): Step {
return new MinifyHtmlStep(
key,
new KeyedStoreGetInput(htmlSourceStore, key),
new WrapInObjectOutput(
key,
new KeyedStoreSetOutput(zipContentStore, key)
)
);
},
writesToStores: [zipContentStore],
},
},
};
export = minifyHtmlPlugin;