Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.

v3.6.0

Compare
Choose a tag to compare
@mmiller42 mmiller42 released this 30 Sep 23:18
· 17 commits to master since this release

This is a summary of the differences between v3.6.0 and v3.5.3.

Commits

Show commits
SHA Author Committed Message
c34efb9 mmiller42 2017-9-18 updating deps
5ee108a mmiller42 2017-9-30 Add attributes to tags feature
a9195ed mmiller42 2017-9-30 With new version of html-webpack-include-assets-plugin
d003c74 mmiller42 2017-9-30 Merge pull request #22 from mmiller42/custom-attributes
Add attributes to tags feature
c9be5ef mmiller42 2017-9-30 3.6.0

Changed files

Show changed files

README.md

@@ -44,6 +44,9 @@ The constructor takes a configuration object with the following properties.
 | `externals` | array<object> | An array of vendor modules that will be excluded from your Webpack bundle and added as `script` or `link` tags in your HTML output. | *None* |
 | `externals[].module` | string | The name of the vendor module. This should match the package name, e.g. if you are writing `import React from 'react'`, this would be `react`. | *None* |
 | `externals[].entry` | string \| array&lt;string&gt; \| object \| array&lt;object \| string&gt; | The path, relative to the vendor module directory, to its pre-bundled distro file. e.g. for React, use `dist/react.js`, since the file exists at `node_modules/react/dist/react.js`. Specify an array if there are multiple CSS/JS files to inject. To use a CDN instead, simply use a fully qualified URL beginning with `http://`, `https://`, or `//`.<br><br>For entries whose type (JS or CSS) cannot be inferred by file extension, pass an object such as `{ path: 'https://some/url', type: 'css' }` (or `type: 'js'`). | *None* |
+| `externals[].entry.path` | string | If entry is an object, the path to the asset. | *None* |
+| `externals[].entry.type` | `'js'`\|`'css'` | The asset type, if it cannot be inferred. | *Inferred by extension when possible* |
+| `externals[].entry.attributes` | object.&lt;string,string&gt; | Additional attributes to add to the injected tag. | `{}` |
 | `externals[].global` | string \| null | For JavaScript modules, this is the name of the object globally exported by the vendor's dist file. e.g. for React, use `React`, since `react.js` creates a `window.React` global. For modules without an export (such as CSS), omit this property or use `null`. | `null` |
 | `externals[].supplements` | array&lt;string&gt; | For modules that require additional resources, specify globs of files to copy over to the output. e.g. for Bootstrap CSS, use `['dist/fonts/']`, since Glyphicon fonts are referenced in the CSS and exist at `node_modules/bootstrap/dist/fonts/`. | `[]` |
 | `externals[].append` | boolean | Set to true to inject this module after your Webpack bundles. | `false` |
@@ -266,6 +269,33 @@ new HtmlWebpackExternalsPlugin({
 })
 ​```
 
+### Adding custom attributes to tags example
+
+Sometimes you may want to add custom attributes to the link or script tags that are injected.
+
+This example does not require the `jquery` module to be installed. It:
+
+1. adds `jquery` to your Webpack config's `externals` object to exclude it from your bundle, telling it to expect a global object called `jQuery` (on the `window` object)
+1. adds `<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>` to your HTML file, before your chunks
+
+​```js
+new HtmlWebpackExternalsPlugin({
+  externals: [
+    {
+      module: 'jquery',
+      entry: {
+        path: 'https://code.jquery.com/jquery-3.2.1.js',
+        attributes: {
+          integrity: 'sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=',
+          crossorigin: 'anonymous',
+        },
+      },
+      global: 'jQuery',
+    },
+  ],
+})
+​```
+
 ### Specifying which HTML files to affect example
 
 If you are using multiple instances of html-webpack-plugin, by default the assets will be injected into every file. This is configurable.

package-lock.json

Inline diff not displayed. View the whole file

package.json

@@ -1,6 +1,6 @@
 {
   "name": "html-webpack-externals-plugin",
-  "version": "3.5.3",
+  "version": "3.6.0",
   "description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
   "keywords": [
     "htmlwebpackplugin",
@@ -46,7 +46,7 @@
     "babel-preset-env": "^1.6.0",
     "babel-register": "^6.24.1",
     "bootstrap": "^3.3.7",
-    "create-github-release": "^1.1.0",
+    "create-github-release": "^1.4.1",
     "css-loader": "^0.28.4",
     "escape-string-regexp": "^1.0.5",
     "extract-text-webpack-plugin": "^3.0.0",
@@ -65,6 +65,6 @@
   "dependencies": {
     "ajv": "^5.2.2",
     "copy-webpack-plugin": "^4.0.1",
-    "html-webpack-include-assets-plugin": "^1.0.0"
+    "html-webpack-include-assets-plugin": "^1.0.1"
   }
 }

src/HtmlWebpackExternalsPlugin.js

Inline diff not displayed. View the whole file

src/configSchema.json

@@ -20,9 +20,19 @@
                 "type": {
                   "type": "string",
                   "enum": ["js", "css"]
+                },
+                "attributes": {
+                  "type": "object",
+                  "patternProperties": {
+                    "^.+$": {
+                      "type": "string"
+                    }
+                  },
+                  "additionalProperties": false,
+                  "default": {}
                 }
               },
-              "required": ["path", "type"]
+              "required": ["path"]
             },
             "minItems": 1,
             "properties": {
@@ -32,9 +42,19 @@
               "type": {
                 "type": "string",
                 "enum": ["js", "css"]
+              },
+              "attributes": {
+                "type": "object",
+                "patternProperties": {
+                  "^.+$": {
+                    "type": "string"
+                  }
+                },
+                "additionalProperties": false,
+                "default": {}
               }
             },
-            "required": ["path", "type"]
+            "required": ["path"]
           },
           "global": {
             "type": ["string", "null"],

test/HtmlWebpackExternalsPlugin.spec.js

Inline diff not displayed. View the whole file

test/utils/index.js

Inline diff not displayed. View the whole file