Passed
Push — master ( 1468f4...b88d56 )
by Andrew
08:39 queued 05:37
created

src/@types/rollup-plugin-critical.d.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 49
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 18
mnd 0
bc 0
fnc 1
dl 0
loc 49
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A rollup-plugin-critical.d.ts ➔ PluginCritical 0 10 1
1
import {Plugin} from 'rollup';
2
import {CriticalConfig} from './critical';
3
4
export interface CriticalPages {
5
    /** Combined with `criticalUrl` to determine the URLs to scrape for Critical CSS */
6
    uri: string;
7
    /** Critical CSS files are named with the `template` path, and saved to the `criticalBase` directory */
8
    template: string;
9
}
10
11
export interface CriticalPluginConfig {
12
    /**
13
     * The base URL to use in combination with the `criticalPages` `uri`s to determine the URLs to scrape for Critical CSS.
14
     * This can also be a file system path. This is combined with `criticalPages.uri`
15
     * to determine pages to scrap for critical CSS.
16
     * Determines the `criticalConfig.src` property
17
     */
18
    criticalUrl: string;
19
    /**
20
     * The base file system path to where the generated Critical CSS file should be saved.
21
     * This is combined with `criticalPages.template` with `_critical.min.css` appended
22
     * to it to determine the saved critical CSS file name.
23
     * Determines the `criticalConfig.target` property
24
     */
25
    criticalBase?: string;
26
    /**
27
     * An array objects that contain the page `uri`s that are combined with the `criticalUrl` to
28
     * determine the URLs to scrape for Critical CSS. The resulting files are named with the
29
     * `template` path, and saved to the `criticalBase` directory
30
     */
31
    criticalPages: Partial<CriticalPages>[];
32
    /**
33
     * This is the full [config for critical](https://github.com/addyosmani/critical#options) that is passed
34
     * through to the `critical` package.
35
     * You may optionally override any properties you like here
36
     */
37
    criticalConfig?: Partial<CriticalConfig>;
38
}
39
40
/**
41
 * [Vite.js](https://vitejs.dev/) & [Rollup](https://rollupjs.org/) plugin for generating critical CSS
42
 * that uses the [critical](https://github.com/addyosmani/critical) generator under the hood.
43
 *
44
 * @param {CriticalPluginConfig} pluginConfig - the plugin configuration object
45
 * @param {Function} callback - callback upon completion of the critical CSS generation
46
 * @constructor
47
 */
48
export function PluginCritical(pluginConfig: CriticalPluginConfig, callback?: Function): Plugin;
49