@@ -8,21 +8,15 @@ Most developers still transpile their code to ES5 and bundle it with polyfills t
8
8
But for newer browsers this transpiled code is unnecessary and probably slower then ES6+ code.
9
9
The Idea is to create two bundles, one modern es6+ bundle and one legacy es5 bundle.
10
10
11
-
12
11
### What? How do you do that?
13
- The Solution is to provide two script tags, one with type=module (es6+ code) and one with "nomodule" (es5 code).
12
+ The solution is to provide two script tags, one with type=module (es6+ code) and one with "nomodule" (es5 code).
14
13
Modern Browser will now only load the script tag with type=module while legacy browser only load the script tag with "nomodule".
15
14
16
- ### Why do i need this addon?
17
- This plugin for html-webpack-plugin generates script tags for module and nomodule for a webpack multi build configuration.
18
-
19
15
### Will some browser still download both bundles?
20
16
21
- Yeah some browser like Safari, IE11, Edge are downloading both bundles, but only executing one.
22
-
23
- We have integrated a clever fix for this.
24
-
25
- We creating a script tag with module / nomodule and in this script tags we are dynamically adding the script tags for the actual javascript resources.
17
+ Some browser like Safari, IE11, Edge are downloading both bundles, but only executing one.
18
+ This plugin has integrated a clever fix for this.
19
+ By creating a script tag with module / nomodule which dynamically injects the actual script tags for the javascript resources.
26
20
27
21
```
28
22
<script type="module">
@@ -33,19 +27,31 @@ We creating a script tag with module / nomodule and in this script tags we are d
33
27
</script>
34
28
```
35
29
30
+ ### Why do i need this addon?
31
+ This plugin for html-webpack-plugin generates script tags for module and nomodule for a webpack multi build configuration.
32
+
33
+ ### Async CSS Loading
34
+ The included template add's tags for async (non blocking) css
35
+ ```
36
+ <link href="app.css" rel="stylesheet" media="nope!" onload="this.media='all'">
37
+ ```
38
+
36
39
### Read about webpack multi build configuration
37
40
https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations
38
41
39
42
### How to use this addon?
40
- You should only use this addon for multi-builds.
41
43
44
+ Check out my [ Example Project] ( https://github.com/firsttris/html-webpack-multi-build-plugin/tree/master/example )
45
+
46
+ Summarized
42
47
43
48
#### Package.json
44
49
```
45
50
"scripts": {
46
51
build:multi": "webpack --env.build=multi"
47
52
}
48
- ```
53
+ ```
54
+
49
55
#### webpack.config
50
56
```
51
57
// Legacy webpack config needs to include 'legacy'
@@ -59,7 +65,9 @@ You should only use this addon for multi-builds.
59
65
const htmlWebpackMultiBuildPlugin = require('html-webpack-multi-build-plugin');
60
66
const multiBuildMode = process.env.build === 'multi'
61
67
62
- const template = multiBuildMode ? require.resolve('html-webpack-multi-build-plugin/template.ejs') : require.resolve('html-webpack-plugin/default_index.ejs');
68
+ const template = multiBuildMode
69
+ ? require.resolve('html-webpack-multi-build-plugin/template.ejs')
70
+ : require.resolve('html-webpack-plugin/default_index.ejs');
63
71
64
72
config.plugins: [
65
73
new htmlWebpackPlugin(
0 commit comments