@rsbuild/core 1.0.0-alpha.6 → 1.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title><%= htmlWebpackPlugin.options.title %></title>
6
+ </head>
7
+ <body>
8
+ </body>
9
+ </html>
@@ -0,0 +1,285 @@
1
+ import { AsyncSeriesWaterfallHook } from '@rspack/lite-tapable';
2
+ import { Compiler, Compilation } from '@rspack/core';
3
+
4
+ declare class HtmlRspackPlugin {
5
+ constructor(options?: HtmlRspackPlugin.Options);
6
+
7
+ userOptions: HtmlRspackPlugin.Options;
8
+
9
+ /** Current HtmlRspackPlugin Major */
10
+ version: number;
11
+
12
+ /**
13
+ * Options after html-webpack-plugin has been initialized with defaults
14
+ */
15
+ options?: HtmlRspackPlugin.ProcessedOptions;
16
+
17
+ apply(compiler: Compiler): void;
18
+
19
+ static getHooks(compilation: Compilation): HtmlRspackPlugin.Hooks;
20
+
21
+ /**
22
+ * Static helper to create a tag object to be get injected into the dom
23
+ */
24
+ static createHtmlTagObject(
25
+ tagName: string,
26
+ attributes?: { [attributeName: string]: string | boolean },
27
+ innerHTML?: string,
28
+ ): HtmlRspackPlugin.HtmlTagObject;
29
+
30
+ static readonly version: number;
31
+ }
32
+
33
+ declare namespace HtmlRspackPlugin {
34
+ type MinifyOptions = HtmlMinifierOptions;
35
+
36
+ interface Options {
37
+ /**
38
+ * Emit the file only if it was changed.
39
+ * @default true
40
+ */
41
+ cache?: boolean;
42
+ /**
43
+ * List all entries which should be injected
44
+ */
45
+ chunks?: 'all' | string[];
46
+ /**
47
+ * Allows to control how chunks should be sorted before they are included to the html.
48
+ * @default 'auto'
49
+ */
50
+ chunksSortMode?:
51
+ | 'auto'
52
+ // `none` is deprecated and an alias for `auto` now.
53
+ | 'none'
54
+ | 'manual'
55
+ | ((entryNameA: string, entryNameB: string) => number);
56
+ /**
57
+ * List all entries which should not be injected
58
+ */
59
+ excludeChunks?: string[];
60
+ /**
61
+ * Path to the favicon icon
62
+ */
63
+ favicon?: false | string;
64
+ /**
65
+ * The file to write the HTML to.
66
+ * Supports subdirectories eg: `assets/admin.html`
67
+ * [name] will be replaced by the entry name
68
+ * Supports a function to generate the name
69
+ *
70
+ * @default 'index.html'
71
+ */
72
+ filename?: string | ((entryName: string) => string);
73
+ /**
74
+ * By default the public path is set to `auto` - that way the html-webpack-plugin will try
75
+ * to set the publicPath according to the current filename and the webpack publicPath setting
76
+ */
77
+ publicPath?: string | 'auto';
78
+ /**
79
+ * If `true` then append a unique `webpack` compilation hash to all included scripts and CSS files.
80
+ * This is useful for cache busting
81
+ */
82
+ hash?: boolean;
83
+ /**
84
+ * Inject all assets into the given `template` or `templateContent`.
85
+ */
86
+ inject?:
87
+ | false // Don't inject scripts
88
+ | true // Inject scripts into body
89
+ | 'body' // Inject scripts into body
90
+ | 'head'; // Inject scripts into head
91
+ /**
92
+ * Set up script loading
93
+ * blocking will result in <script src="..."></script>
94
+ * defer will result in <script defer src="..."></script>
95
+ *
96
+ * @default 'defer'
97
+ */
98
+ scriptLoading?: 'blocking' | 'defer' | 'module' | 'systemjs-module';
99
+ /**
100
+ * Inject meta tags
101
+ */
102
+ meta?:
103
+ | false // Disable injection
104
+ | {
105
+ [name: string]:
106
+ | string
107
+ | false // name content pair e.g. {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`
108
+ | { [attributeName: string]: string | boolean }; // custom properties e.g. { name:"viewport" content:"width=500, initial-scale=1" }
109
+ };
110
+ /**
111
+ * A function to minify the HTML
112
+ */
113
+ minify?: (html: string) => string | Promise<string>;
114
+ /**
115
+ * Render errors into the HTML page
116
+ */
117
+ showErrors?: boolean;
118
+ /**
119
+ * The `webpack` require path to the template.
120
+ * @see https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md
121
+ */
122
+ template?: string;
123
+ /**
124
+ * Allow to use a html string instead of reading from a file
125
+ */
126
+ templateContent?:
127
+ | false // Use the template option instead to load a file
128
+ | string
129
+ | ((templateParameters: {
130
+ [option: string]: any;
131
+ }) => string | Promise<string>)
132
+ | Promise<string>;
133
+ /**
134
+ * Allows to overwrite the parameters used in the template
135
+ */
136
+ templateParameters?:
137
+ | false // Pass an empty object to the template function
138
+ | ((
139
+ compilation: Compilation,
140
+ assets: {
141
+ publicPath: string;
142
+ js: Array<string>;
143
+ css: Array<string>;
144
+ favicon?: string;
145
+ },
146
+ assetTags: {
147
+ headTags: HtmlTagObject[];
148
+ bodyTags: HtmlTagObject[];
149
+ },
150
+ options: ProcessedOptions,
151
+ ) => { [option: string]: any } | Promise<{ [option: string]: any }>)
152
+ | { [option: string]: any };
153
+ /**
154
+ * The title to use for the generated HTML document
155
+ */
156
+ title?: string;
157
+ /**
158
+ * Enforce self closing tags e.g. <link />
159
+ */
160
+ xhtml?: boolean;
161
+ /**
162
+ * In addition to the options actually used by this plugin, you can use this hash to pass arbitrary data through
163
+ * to your template.
164
+ */
165
+ [option: string]: any;
166
+ }
167
+
168
+ /**
169
+ * The plugin options after adding default values
170
+ */
171
+ interface ProcessedOptions extends Required<Options> {
172
+ filename: string;
173
+ minify?: Options['minify'];
174
+ }
175
+
176
+ /**
177
+ * The values which are available during template execution
178
+ *
179
+ * Please keep in mind that the `templateParameter` options allows to change them
180
+ */
181
+ interface TemplateParameter {
182
+ compilation: Compilation;
183
+ htmlWebpackPlugin: {
184
+ tags: {
185
+ headTags: HtmlTagObject[];
186
+ bodyTags: HtmlTagObject[];
187
+ };
188
+ files: {
189
+ publicPath: string;
190
+ js: Array<string>;
191
+ css: Array<string>;
192
+ favicon?: string;
193
+ };
194
+ options: Options;
195
+ };
196
+ webpackConfig: any;
197
+ }
198
+
199
+ interface Hooks {
200
+ alterAssetTags: AsyncSeriesWaterfallHook<{
201
+ assetTags: {
202
+ scripts: HtmlTagObject[];
203
+ styles: HtmlTagObject[];
204
+ meta: HtmlTagObject[];
205
+ };
206
+ publicPath: string;
207
+ outputName: string;
208
+ plugin: HtmlRspackPlugin;
209
+ }>;
210
+
211
+ alterAssetTagGroups: AsyncSeriesWaterfallHook<{
212
+ headTags: HtmlTagObject[];
213
+ bodyTags: HtmlTagObject[];
214
+ outputName: string;
215
+ publicPath: string;
216
+ plugin: HtmlRspackPlugin;
217
+ }>;
218
+
219
+ afterTemplateExecution: AsyncSeriesWaterfallHook<{
220
+ html: string;
221
+ headTags: HtmlTagObject[];
222
+ bodyTags: HtmlTagObject[];
223
+ outputName: string;
224
+ plugin: HtmlRspackPlugin;
225
+ }>;
226
+
227
+ beforeAssetTagGeneration: AsyncSeriesWaterfallHook<{
228
+ assets: {
229
+ publicPath: string;
230
+ js: Array<string>;
231
+ css: Array<string>;
232
+ favicon?: string;
233
+ };
234
+ outputName: string;
235
+ plugin: HtmlRspackPlugin;
236
+ }>;
237
+
238
+ beforeEmit: AsyncSeriesWaterfallHook<{
239
+ html: string;
240
+ outputName: string;
241
+ plugin: HtmlRspackPlugin;
242
+ }>;
243
+
244
+ afterEmit: AsyncSeriesWaterfallHook<{
245
+ outputName: string;
246
+ plugin: HtmlRspackPlugin;
247
+ }>;
248
+ }
249
+
250
+ /**
251
+ * A tag element according to the htmlWebpackPlugin object notation
252
+ */
253
+ interface HtmlTagObject {
254
+ /**
255
+ * Attributes of the html tag
256
+ * E.g. `{'disabled': true, 'value': 'demo'}`
257
+ */
258
+ attributes: {
259
+ [attributeName: string]: string | boolean | null | undefined;
260
+ };
261
+ /**
262
+ * The tag name e.g. `'div'`
263
+ */
264
+ tagName: string;
265
+ /**
266
+ * The inner HTML
267
+ */
268
+ innerHTML?: string;
269
+ /**
270
+ * Whether this html must not contain innerHTML
271
+ * @see https://www.w3.org/TR/html5/syntax.html#void-elements
272
+ */
273
+ voidTag: boolean;
274
+ /**
275
+ * Meta information about the tag
276
+ * E.g. `{'plugin': 'html-webpack-plugin'}`
277
+ */
278
+ meta: {
279
+ plugin?: string;
280
+ [metaAttributeName: string]: any;
281
+ };
282
+ }
283
+ }
284
+
285
+ export { HtmlRspackPlugin as default };