1 | // Type definitions for postcss-url 10.0
|
2 | // Project: https://github.com/postcss/postcss-url
|
3 | // Definitions by: Silas Rech <https://github.com/lenovouser>
|
4 | // Remco Haszing <https://github.com/remcohaszing>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 | // TypeScript Version: 2.8
|
7 |
|
8 | /// <reference types="node" />
|
9 |
|
10 | import { PluginCreator } from 'postcss';
|
11 |
|
12 | declare namespace url {
|
13 | type CustomTransformFunction = (
|
14 | asset: {
|
15 | /**
|
16 | * Original URL.
|
17 | */
|
18 | url: string;
|
19 |
|
20 | /**
|
21 | * URL pathname.
|
22 | */
|
23 | pathname?: string | undefined;
|
24 |
|
25 | /**
|
26 | * Absolute path to asset.
|
27 | */
|
28 | absolutePath?: string | undefined;
|
29 |
|
30 | /**
|
31 | * Current relative path to asset.
|
32 | */
|
33 | relativePath?: string | undefined;
|
34 |
|
35 | /**
|
36 | * Querystring from URL.
|
37 | */
|
38 | search?: string | undefined;
|
39 |
|
40 | /**
|
41 | * Hash from URL.
|
42 | */
|
43 | hash?: string | undefined;
|
44 | },
|
45 | dir: {
|
46 | /**
|
47 | * PostCSS from option.
|
48 | */
|
49 | from?: string | undefined;
|
50 |
|
51 | /**
|
52 | * PostCSS to option.
|
53 | */
|
54 | to?: string | undefined;
|
55 |
|
56 | /**
|
57 | * File path.
|
58 | */
|
59 | file?: string | undefined;
|
60 | },
|
61 | ) => string;
|
62 | type CustomHashFunction = (file: Buffer) => string;
|
63 | type CustomFilterFunction = (file: string) => boolean;
|
64 |
|
65 | interface Options {
|
66 | /**
|
67 | * URL rewriting mechanism.
|
68 | *
|
69 | * @default 'rebase'
|
70 | */
|
71 | url?: 'copy' | 'inline' | 'rebase' | CustomTransformFunction | undefined;
|
72 |
|
73 | /**
|
74 | * Specify the maximum file size to inline (in kilobytes).
|
75 | */
|
76 | maxSize?: number | undefined;
|
77 |
|
78 | /**
|
79 | * Do not warn when an SVG URL with a fragment is inlined.
|
80 | * PostCSS-URL does not support partial inlining.
|
81 | * The entire SVG file will be inlined.
|
82 | * By default a warning will be issued when this occurs.
|
83 | *
|
84 | * @default false
|
85 | */
|
86 | ignoreFragmentWarning?: boolean | undefined;
|
87 |
|
88 | /**
|
89 | * Reduce size of inlined svg (IE9+, Android 3+)
|
90 | *
|
91 | * @default false
|
92 | */
|
93 | optimizeSvgEncode?: boolean | undefined;
|
94 |
|
95 | /**
|
96 | * Determine wether a file should be inlined.
|
97 | */
|
98 | filter?: RegExp | CustomFilterFunction | string | undefined;
|
99 |
|
100 | /**
|
101 | * Specifies whether the URL's fragment identifer value, if present, will be added to the inlined data URI.
|
102 | *
|
103 | * @default false
|
104 | */
|
105 | includeUriFragment?: boolean | undefined;
|
106 |
|
107 | /**
|
108 | * The fallback method to use if the maximum size is exceeded or the URL contains a hash.
|
109 | */
|
110 | fallback?: CustomTransformFunction | undefined;
|
111 |
|
112 | /**
|
113 | * Specify the base path or list of base paths where to search images from.
|
114 | */
|
115 | basePath?: string | string[] | undefined;
|
116 |
|
117 | /**
|
118 | * The assets files will be copied in that destination.
|
119 | *
|
120 | * @default false
|
121 | */
|
122 | assetsPath?: boolean | string | undefined;
|
123 |
|
124 | /**
|
125 | * Rename the path of the files by a hash name.
|
126 | *
|
127 | * @default false
|
128 | */
|
129 | useHash?: boolean | undefined;
|
130 |
|
131 | /**
|
132 | * Hash options
|
133 | */
|
134 | hashOptions?:
|
135 | | {
|
136 | /**
|
137 | * Hashing method or custom function.
|
138 | */
|
139 | method?: 'xxhash32' | 'xxhash64' | CustomHashFunction | undefined;
|
140 |
|
141 | /**
|
142 | * Shrink hast to certain length.
|
143 | */
|
144 | shrink?: number | undefined;
|
145 |
|
146 | /**
|
147 | * Append the original filename in resulting filename.
|
148 | */
|
149 | append?: boolean | undefined;
|
150 | }
|
151 | | undefined;
|
152 | }
|
153 |
|
154 | type Url = PluginCreator<Options | Options[]>;
|
155 | }
|
156 |
|
157 | declare const url: url.Url;
|
158 | export = url;
|