progress on migrating to heex templates and font-icons

This commit is contained in:
Adam Piontek 2022-08-13 07:32:36 -04:00
parent d43daafdb7
commit 3eff955672
21793 changed files with 2161968 additions and 16895 deletions

View file

@ -0,0 +1,47 @@
import { Compiler, Compilation } from "webpack";
type StringRegExpArray = Array<RegExp | string>;
type ComplexSafelist = {
standard?: StringRegExpArray;
deep?: RegExp[];
greedy?: RegExp[];
variables?: StringRegExpArray;
keyframes?: StringRegExpArray;
};
type ExtractorFunction$0<T = string> = (content: T) => string[];
interface Extractors$0 {
extensions: string[];
extractor: ExtractorFunction$0;
}
type PathFunction = () => string[];
type SafelistFunction = () => ComplexSafelist;
type BlocklistFunction = () => StringRegExpArray;
interface UserDefinedOptions$0 {
paths: string[] | PathFunction;
defaultExtractor?: ExtractorFunction$0;
extractors?: Array<Extractors$0>;
fontFace?: boolean;
keyframes?: boolean;
moduleExtensions?: string[];
output?: string;
rejected?: boolean;
stdin?: boolean;
stdout?: boolean;
variables?: boolean;
verbose?: boolean;
safelist?: StringRegExpArray | ComplexSafelist | SafelistFunction;
blocklist?: StringRegExpArray | BlocklistFunction;
skippedContentGlobs?: Array<string>;
only?: string[];
}
type PurgedStats = {
[index: string]: string[];
};
declare class PurgeCSSPlugin {
options: UserDefinedOptions$0;
purgedStats: PurgedStats;
constructor(options: UserDefinedOptions$0);
apply(compiler: Compiler): void;
initializePlugin(compilation: Compilation): void;
runPluginHook(compilation: Compilation, entryPaths: string[]): Promise<void>;
}
export { PurgeCSSPlugin as default };

View file

@ -0,0 +1,47 @@
import { Compiler, Compilation } from "webpack";
type StringRegExpArray = Array<RegExp | string>;
type ComplexSafelist = {
standard?: StringRegExpArray;
deep?: RegExp[];
greedy?: RegExp[];
variables?: StringRegExpArray;
keyframes?: StringRegExpArray;
};
type ExtractorFunction$0<T = string> = (content: T) => string[];
interface Extractors$0 {
extensions: string[];
extractor: ExtractorFunction$0;
}
type PathFunction = () => string[];
type SafelistFunction = () => ComplexSafelist;
type BlocklistFunction = () => StringRegExpArray;
interface UserDefinedOptions$0 {
paths: string[] | PathFunction;
defaultExtractor?: ExtractorFunction$0;
extractors?: Array<Extractors$0>;
fontFace?: boolean;
keyframes?: boolean;
moduleExtensions?: string[];
output?: string;
rejected?: boolean;
stdin?: boolean;
stdout?: boolean;
variables?: boolean;
verbose?: boolean;
safelist?: StringRegExpArray | ComplexSafelist | SafelistFunction;
blocklist?: StringRegExpArray | BlocklistFunction;
skippedContentGlobs?: Array<string>;
only?: string[];
}
type PurgedStats = {
[index: string]: string[];
};
declare class PurgeCSSPlugin {
options: UserDefinedOptions$0;
purgedStats: PurgedStats;
constructor(options: UserDefinedOptions$0);
apply(compiler: Compiler): void;
initializePlugin(compilation: Compilation): void;
runPluginHook(compilation: Compilation, entryPaths: string[]): Promise<void>;
}
export { PurgeCSSPlugin as default };

View file

@ -0,0 +1 @@
import{existsSync as t}from"fs";import s from"path";import o,{defaultOptions as e}from"purgecss";import{ConcatSource as i}from"webpack-sources";const n=[".css",".scss",".styl",".sass",".less"];export default class{constructor(t){this.purgedStats={},this.options=t}apply(t){t.hooks.compilation.tap("PurgeCSS",this.initializePlugin.bind(this))}initializePlugin(s){s.hooks.additionalAssets.tapPromise("PurgeCSS",(()=>{const o="function"==typeof this.options.paths?this.options.paths():this.options.paths;return o.forEach((s=>{if(!t(s))throw new Error(`Path ${s} does not exist.`)})),this.runPluginHook(s,o)}))}async runPluginHook(t,r){const c=Object.entries(t.assets).filter((([t])=>function(t,o){const e=s.extname((i=t).includes("?")?i.split("?").slice(0,-1).join(""):i);var i;return o.includes(e)}(t,[".css"])));for(const s of t.chunks){const a=c.filter((([t])=>this.options.only?this.options.only.some((s=>t.includes(s))):Array.isArray(s.files)?s.files.includes(t):s.files.has(t)));for(const[s,c]of a){const a=r.filter((t=>!n.some((s=>t.endsWith(s))))),l={...e,...this.options,content:a,css:[{raw:c.source().toString()}]};"function"==typeof l.safelist&&(l.safelist=l.safelist()),"function"==typeof l.blocklist&&(l.blocklist=l.blocklist());const f=(await(new o).purge({content:l.content,css:l.css,defaultExtractor:l.defaultExtractor,extractors:l.extractors,fontFace:l.fontFace,keyframes:l.keyframes,output:l.output,rejected:l.rejected,variables:l.variables,safelist:l.safelist,blocklist:l.blocklist}))[0];f.rejected&&(this.purgedStats[s]=f.rejected),t.updateAsset(s,new i(f.css))}}}}

View file

@ -0,0 +1 @@
"use strict";var t=require("fs"),s=require("path"),e=require("purgecss"),o=require("webpack-sources");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=i(s),r=i(e);const c=[".css",".scss",".styl",".sass",".less"];module.exports=class{constructor(t){this.purgedStats={},this.options=t}apply(t){t.hooks.compilation.tap("PurgeCSS",this.initializePlugin.bind(this))}initializePlugin(s){s.hooks.additionalAssets.tapPromise("PurgeCSS",(()=>{const e="function"==typeof this.options.paths?this.options.paths():this.options.paths;return e.forEach((s=>{if(!t.existsSync(s))throw new Error(`Path ${s} does not exist.`)})),this.runPluginHook(s,e)}))}async runPluginHook(t,s){const i=Object.entries(t.assets).filter((([t])=>function(t,s){const e=n.default.extname((o=t).includes("?")?o.split("?").slice(0,-1).join(""):o);var o;return s.includes(e)}(t,[".css"])));for(const n of t.chunks){const a=i.filter((([t])=>this.options.only?this.options.only.some((s=>t.includes(s))):Array.isArray(n.files)?n.files.includes(t):n.files.has(t)));for(const[i,n]of a){const a=s.filter((t=>!c.some((s=>t.endsWith(s))))),l={...e.defaultOptions,...this.options,content:a,css:[{raw:n.source().toString()}]};"function"==typeof l.safelist&&(l.safelist=l.safelist()),"function"==typeof l.blocklist&&(l.blocklist=l.blocklist());const u=(await(new r.default).purge({content:l.content,css:l.css,defaultExtractor:l.defaultExtractor,extractors:l.extractors,fontFace:l.fontFace,keyframes:l.keyframes,output:l.output,rejected:l.rejected,variables:l.variables,safelist:l.safelist,blocklist:l.blocklist}))[0];u.rejected&&(this.purgedStats[i]=u.rejected),t.updateAsset(i,new o.ConcatSource(u.css))}}}};