@@ -29,34 +29,57 @@ module.exports = {
29
29
files: [
30
30
{
31
31
match: / . * \. woff2/ ,
32
- attributes: { rel : ' preload ' , as: ' font' , type: ' font/woff2' , crossorigin: true },
32
+ attributes: {as: ' font' , type: ' font/woff2' , crossorigin: true },
33
33
},
34
34
{
35
35
match: / vendors\. [a-z -0-9 ] * . css/ ,
36
- attributes: { rel : ' preload ' , as: ' style' },
36
+ attributes: {as: ' style' },
37
37
},
38
- ],
38
+ ]
39
39
})
40
40
]
41
41
}
42
42
```
43
43
44
+ ** Options**
44
45
45
- ** HTML file**
46
+ * files: An array of files object
47
+ * match: A regular expression to target files you want to preload
48
+ * attributes: Any attributes you want to use. The plugin will add the attribute ` rel="preload" ` by default.
46
49
47
- Add ` <!-- html-webpack-inject-preload --> ` to indicate where to inject preload links.
50
+ ** Usage**
51
+
52
+ The plugin is really simple to use. The plugin injects in ` headTags ` , before any link, the preload elements.
53
+
54
+ For example
48
55
49
56
``` html
50
57
<!DOCTYPE html>
51
58
<html >
52
59
<head >
53
60
<meta charset =" utf-8" >
54
61
<title >Webpack App</title >
55
- <!-- html-webpack-inject-preload -->
56
- <link href =" dist/main.css" >
62
+ <%= htmlWebpackPlugin.tags.headTags %>
57
63
</head >
58
64
<body >
59
65
<script src =" index_bundle.js" ></script >
60
66
</body >
61
67
</html >
62
- ```
68
+ ```
69
+
70
+ will generate
71
+
72
+ ``` html
73
+ <!DOCTYPE html>
74
+ <html >
75
+ <head >
76
+ <meta charset =" utf-8" >
77
+ <title >Webpack App</title >
78
+ <link href =" dist/fonts/font.woff2" rel =" preload" type =" font/woff2" crossorigin >
79
+ <link href =" dist/css/main.css" >
80
+ </head >
81
+ <body >
82
+ <script src =" index_bundle.js" ></script >
83
+ </body >
84
+ </html >
85
+ ```
0 commit comments