MCPcopy
hub / github.com/FullHuman/purgecss / purge

Method purge

packages/purgecss/src/index.ts:810–847  ·  view source on GitHub ↗

* Remove unused CSS * * @param userOptions - PurgeCSS options or path to the configuration file * @returns an array of object containing the filename and the associated CSS * * @example Using a configuration file named purgecss.config.js * ```ts * const purgeCSSResults = await n

(
    userOptions: UserDefinedOptions | string | undefined,
  )

Source from the content-addressed store, hash-verified

808 * ```
809 */
810 public async purge(
811 userOptions: UserDefinedOptions | string | undefined,
812 ): Promise<ResultPurge[]> {
813 this.options =
814 typeof userOptions !== "object"
815 ? await setOptions(userOptions)
816 : {
817 ...defaultOptions,
818 ...userOptions,
819 safelist: standardizeSafelist(userOptions.safelist),
820 };
821 const { content, css, extractors, safelist } = this.options;
822
823 if (this.options.variables) {
824 this.variablesStructure.safelist = safelist.variables || [];
825 }
826
827 const fileFormatContents = content.filter(
828 (o) => typeof o === "string",
829 ) as string[];
830 const rawFormatContents = content.filter(
831 (o) => typeof o === "object",
832 ) as RawContent[];
833
834 const cssFileSelectors = await this.extractSelectorsFromFiles(
835 fileFormatContents,
836 extractors,
837 );
838 const cssRawSelectors = await this.extractSelectorsFromString(
839 rawFormatContents,
840 extractors,
841 );
842
843 return this.getPurgedCSS(
844 css,
845 mergeExtractorSelectors(cssFileSelectors, cssRawSelectors),
846 );
847 }
848
849 /**
850 * Remove unused CSS variables

Callers 15

gruntPurgeCSSFunction · 0.80
runPluginHookMethod · 0.80
pluginPurgeCSSFunction · 0.80
gulpPurgeCSSFunction · 0.80
runFunction · 0.80
index.test.tsFile · 0.80
rejected.test.tsFile · 0.80
keyframes.test.tsFile · 0.80

Calls 6

getPurgedCSSMethod · 0.95
setOptionsFunction · 0.85
standardizeSafelistFunction · 0.85
mergeExtractorSelectorsFunction · 0.85

Tested by

no test coverage detected