Releases: mmiller42/html-webpack-externals-plugin
v3.8.0
This is a summary of the differences between v3.8.0 and v3.7.0.
Commits
Show commits
SHA | Author | Committed | Message |
---|---|---|---|
447ad29 |
2018-2-17 | improve formatting | |
ebffd34 |
2018-2-17 | improve formatting | |
aaf3060 |
2018-2-17 | indentation with some special space characters | |
cd77258 |
2018-5-4 | use externals array so that external modules that do not contain globals don't throw webpack config errors | |
e574a0a |
2018-5-4 | remove greenkeeper | |
03cbbb3 |
2018-5-4 | 3.8.0 |
Changed files
Show changed files
.circleci/config.yml
@@ -15,9 +15,6 @@ jobs:
npm install npm@latest --no-save &&
sudo rm -rf /usr/local/lib/node_modules/npm &&
sudo mv node_modules/npm /usr/local/lib/node_modules/npm
- - run:
- name: Install greenkeeper-lockfile
- command: sudo npm install -g greenkeeper-lockfile@1
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
@@ -33,12 +30,6 @@ jobs:
- run:
name: Test
command: npm test
- - run:
- name: Update lockfile
- command: greenkeeper-lockfile-update
- - run:
- name: Upload lockfile
- command: greenkeeper-lockfile-upload
- deploy:
name: Publish
command: |
README.md
@@ -1,4 +1,4 @@
-# html-webpack-externals-plugin [![CircleCI](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin.svg?style=svg)](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin) [![Greenkeeper badge](https://badges.greenkeeper.io/mmiller42/html-webpack-externals-plugin.svg)](https://greenkeeper.io/)
+# html-webpack-externals-plugin [![CircleCI](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin.svg?style=svg)](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin)
Webpack plugin that works alongside [`html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin) to use pre-packaged vendor bundles.
@@ -46,12 +46,12 @@ The constructor takes a configuration object with the following properties.
| `externals[].entry` | string \| array<string> \| object \| array<object \| string> | 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.cwpPatternConfig` | object | The properties to set on the [`copy-webpack-plugin` pattern object](https://github.com/webpack-contrib/copy-webpack-plugin#patterns). This object is merged in with the default `from` and `to` properties which are generated by the externals plugin. | `{}` |
-| `externals[].entry.attributes` | object.<string,string> | Additional attributes to add to the injected tag. | `{}` |
+| `externals[].entry`<br>` .cwpPatternConfig` | object | The properties to set on the [`copy-webpack-plugin` pattern object](https://github.com/webpack-contrib/copy-webpack-plugin#patterns). This object is merged in with the default `from` and `to` properties which are generated by the externals plugin. | `{}` |
+| `externals[].entry`<br>` .attributes` | object.<string,string> | 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<string> \| array<object> | 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/`. Supplements can be specified as just an array of paths, or an array of objects with a path and copy plugin pattern object. | `[]` |
-| `externals[].supplements[].path` | string | The glob path to copy assets from. | *None* |
-| `externals[].supplements[].cwpPatternConfig` | object | The properties to set on the [`copy-webpack-plugin` pattern object](https://github.com/webpack-contrib/copy-webpack-plugin#patterns). This object is merged in with the default `from` and `to` properties which are generated by the externals plugin. | `{}` |
+| `externals[].supplements[]`<br>` .path` | string | The glob path to copy assets from. | *None* |
+| `externals[].supplements[]`<br>` .cwpPatternConfig` | object | The properties to set on the [`copy-webpack-plugin` pattern object](https://github.com/webpack-contrib/copy-webpack-plugin#patterns). This object is merged in with the default `from` and `to` properties which are generated by the externals plugin. | `{}` |
| `externals[].append` | boolean | Set to true to inject this module after your Webpack bundles. | `false` |
| `hash` | boolean | Set to true to append the injected module distro paths with a unique hash for cache-busting. | `false` |
| `outputPath` | string | The path (relative to your Webpack `outputPath`) to store externals copied over by this plugin. | `vendor` |
package-lock.json
@@ -1,6 +1,6 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.7.0",
+ "version": "3.8.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
package.json
@@ -1,6 +1,6 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.7.0",
+ "version": "3.8.0",
"description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
"keywords": [
"htmlwebpackplugin",
src/HtmlWebpackExternalsPlugin.js
Inline diff not displayed. View the whole file
test/HtmlWebpackExternalsPlugin.spec.js
Inline diff not displayed. View the whole file
test/utils/index.js
Inline diff not displayed. View the whole file
v3.7.0
This is a summary of the differences between v3.7.0 and v3.6.0.
Commits
Show commits
SHA | Author | Committed | Message |
---|---|---|---|
c9609da |
2018-2-16 | updating dependencies | |
15a0789 |
2018-2-17 | adding full configurability of copy webpack plugin | |
c15d887 |
2018-2-17 | 3.7.0 |
Changed files
Show changed files
.circleci/config.yml
@@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- - image: circleci/node:latest
+ - image: circleci/node:9.5.0
working_directory: ~/html-webpack-externals-plugin
steps:
- checkout
README.md
Inline diff not displayed. View the whole file
package-lock.json
Inline diff not displayed. View the whole file
package.json
@@ -1,6 +1,6 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.6.0",
+ "version": "3.7.0",
"description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
"keywords": [
"htmlwebpackplugin",
@@ -37,34 +37,34 @@
},
"homepage": "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
"devDependencies": {
- "assertion-error": "^1.0.2",
+ "assertion-error": "^1.1.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
- "babel-preset-env": "^1.6.0",
+ "babel-preset-env": "^1.6.1",
"babel-register": "^6.24.1",
- "bootstrap": "^3.3.7",
+ "bootstrap": "^4.0.0",
"create-github-release": "^1.4.1",
- "css-loader": "^0.28.4",
+ "css-loader": "^0.28.9",
"escape-string-regexp": "^1.0.5",
- "extract-text-webpack-plugin": "^3.0.0",
+ "extract-text-webpack-plugin": "^3.0.2",
"html-webpack-plugin": "^2.0.0",
"husky": "^0.14.3",
- "jquery": "^3.2.1",
- "lint-staged": "^4.0.2",
- "mocha": "^3.4.2",
- "prettier": "^1.7.0",
+ "jquery": "^3.3.1",
+ "lint-staged": "^6.1.1",
+ "mocha": "^5.0.1",
+ "prettier": "^1.10.2",
"rimraf": "^2.6.1",
- "webpack": "^3.3.0"
+ "webpack": "^3.11.0"
},
"peerDependencies": {
"html-webpack-plugin": "^2.0.0"
},
"dependencies": {
- "ajv": "^5.2.2",
- "copy-webpack-plugin": "^4.0.1",
- "html-webpack-include-assets-plugin": "^1.0.1"
+ "ajv": "^6.1.1",
+ "copy-webpack-plugin": "^4.4.1",
+ "html-webpack-include-assets-plugin": "^1.0.2"
}
}
src/HtmlWebpackExternalsPlugin.js
Inline diff not displayed. View the whole file
src/configSchema.json
@@ -21,6 +21,10 @@
"type": "string",
"enum": ["js", "css"]
},
+ "cwpPatternConfig": {
+ "type": "object",
+ "default": {}
+ },
"attributes": {
"type": "object",
"patternProperties": {
@@ -43,6 +47,10 @@
"type": "string",
"enum": ["js", "css"]
},
+ "cwpPatternConfig": {
+ "type": "object",
+ "default": {}
+ },
"attributes": {
"type": "object",
"patternProperties": {
@@ -63,7 +71,17 @@
"supplements": {
"type": "array",
"items": {
- "type": "string"
+ "type": ["string", "object"],
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "cwpPatternConfig": {
+ "type": "object",
+ "default": {}
+ }
+ },
+ "required": ["path"]
},
"default": []
},
@@ -96,6 +114,21 @@
"minItems": 1,
"default": null
},
+ "cwpOptions": {
+ "type": "object",
+ "properties": {
+ "context": {
+ "default": "node_modules/"
+ }
+ },
+ "patternProperties": {
+ "^.+$": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false,
+ "default": {}
+ },
"enabled": {
"type": "boolean",
"default": true
test/HtmlWebpackExternalsPlugin.spec.js
Inline diff not displayed. View the whole file
➕ test/fixtures/bower_components/context_test/dist/contextTest.css
Inline diff not displayed. View the whole file
➕ test/fixtures/bower_components/context_test/dist/{a,b}/1.css
Inline diff not displayed. View the whole file
➕ test/fixtures/bower_components/context_test/dist/{a,b}/2.css
Inline diff not displayed. View the whole file
v3.6.0
This is a summary of the differences between v3.6.0 and v3.5.3.
Commits
Show commits
SHA | Author | Committed | Message |
---|---|---|---|
c34efb9 |
2017-9-18 | updating deps | |
5ee108a |
2017-9-30 | Add attributes to tags feature | |
a9195ed |
2017-9-30 | With new version of html-webpack-include-assets-plugin | |
d003c74 |
2017-9-30 | Merge pull request #22 from mmiller42/custom-attributes Add attributes to tags feature |
|
c9be5ef |
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<string> \| object \| array<object \| string> | 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.<string,string> | 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<string> | 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
v3.5.3
What's New in v3.5.3
This is a summary of the differences between v3.5.3 and v3.5.2.
Commits
Show commits
SHA | Author | Committed | Message |
---|---|---|---|
cc3dd0d |
2017-9-17 | adjust release to hide based on line count | |
9f7d056 |
2017-9-17 | 3.5.3 |
Changed files
Show changed files
github-release.config.js
Inline diff not displayed. View the whole file
package-lock.json
@@ -1,6 +1,6 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.5.2",
+ "version": "3.5.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -1446,9 +1446,9 @@
}
},
"create-github-release": {
- "version": "1.0.7",
- "resolved": "https://registry.npmjs.org/create-github-release/-/create-github-release-1.0.7.tgz",
- "integrity": "sha512-rmFtCkP2w+kJq/heR7pm3mDnKChDkP4XUiDkt9j6DQoRHCuWzhOhQB7Uy9dzx4uRVGA2FWIE3C3bmHDfY63bTg==",
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/create-github-release/-/create-github-release-1.1.0.tgz",
+ "integrity": "sha512-zDlLoTleBi4SR5JgJlBgXGfFQhKYdnwsjlgvTdbbxeW59X10Y7tDpdZwdAZdCsmCW5tsP8zsTEyNoRmOmbnilg==",
"dev": true,
"requires": {
"babel-runtime": "6.26.0",
package.json
@@ -1,6 +1,6 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.5.2",
+ "version": "3.5.3",
"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.0.7",
+ "create-github-release": "^1.1.0",
"css-loader": "^0.28.4",
"escape-string-regexp": "^1.0.5",
"extract-text-webpack-plugin": "^3.0.0",
v3.5.2
What's New in v3.5.2
This is a summary of the differences between v3.5.2 and v3.5.1.
Commits
Show commits
SHA | Author | Committed | Message |
---|---|---|---|
f5f0665 |
2017-9-16 | CircleCI 2.0 now supports tags | |
1915fcd |
2017-9-16 | fixing things and using new release tool | |
341d75a |
2017-9-16 | 3.5.2 |
Changed files
Show changed files
.circleci/config.yml
@@ -4,7 +4,6 @@ jobs:
docker:
- image: circleci/node:latest
working_directory: ~/html-webpack-externals-plugin
-
steps:
- checkout
- run:
@@ -24,9 +23,6 @@ jobs:
- run:
name: Install dependencies
command: npm install
- - run:
- name: Update lockfile
- command: greenkeeper-lockfile-update
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
@@ -38,6 +34,9 @@ jobs:
name: Test
command: npm test
- run:
+ name: Update lockfile
+ command: greenkeeper-lockfile-update
+ - run:
name: Upload lockfile
command: greenkeeper-lockfile-upload
- deploy:
@@ -46,8 +45,6 @@ jobs:
export TAG="v$(git log -1 --pretty=%B)"
if echo $TAG | grep "^v[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
npm publish
- npm run build:scripts
- node .circleci/lib/index.js
else
echo "No tag pushed, skipping deploy"
fi
➖ .circleci/scripts/createRelease.js
Inline diff not displayed. View the whole file
➖ .circleci/scripts/index.js
Inline diff not displayed. View the whole file
➕ .prettierrc
@@ -0,0 +1,6 @@
+{
+ "semi": false,
+ "singleQuote": true,
+ "trailingComma": "es5",
+ "printWidth": 100
+}
➕ github-release.config.js
Inline diff not displayed. View the whole file
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.1",
+ "version": "3.5.2",
"description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
"keywords": [
"htmlwebpackplugin",
@@ -10,15 +10,16 @@
],
"main": "lib/index.js",
"scripts": {
+ "build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files",
+ "postpublish": "create-github-release $TAG",
"precommit": "lint-staged",
+ "prettier": "prettier --write 'src/**/*.{js,json}'",
"test": "mocha --require babel-register",
- "build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files",
- "build:scripts": "rm -rf .circleci/lib && babel .circleci/scripts --out-dir .circleci/lib --source-maps",
"watch": "npm run build -- --watch"
},
"lint-staged": {
- "{src,test,.circleci/scripts}.{js,json}": [
- "prettier --write --no-semi --single-quote --trailing-comma es5",
+ "{{src,test}/*.{js,json}},*.js": [
+ "prettier --write",
"git add"
]
},
@@ -42,23 +43,20 @@
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
- "babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.24.1",
"bootstrap": "^3.3.7",
+ "create-github-release": "^1.0.7",
"css-loader": "^0.28.4",
"escape-string-regexp": "^1.0.5",
"extract-text-webpack-plugin": "^3.0.0",
- "github": "^11.0.0",
"html-webpack-plugin": "^2.0.0",
"husky": "^0.14.3",
"jquery": "^3.2.1",
"lint-staged": "^4.0.2",
"mocha": "^3.4.2",
- "mustache": "^2.3.0",
- "prettier": "^1.5.3",
+ "prettier": "^1.7.0",
"rimraf": "^2.6.1",
- "semver-sort": "0.0.4",
"webpack": "^3.3.0"
},
"peerDependencies": {
v3.5.1
What's New in v3.5.1
This is a summary of the differences between v3.5.1 and v3.5.0.
Commits
Show commits
SHA | Author | Message |
---|---|---|
221db49 |
mmiller42 | Adding release notes generator |
2089f39 |
mmiller42 | stop prettifying package.json |
3dde4d5 |
greenkeeper[bot] | fix(package): update html-webpack-include-assets-plugin to version 1.0.0 |
6715986 |
mmiller42 | relaxing requirement |
d165b1e |
mmiller42 | Merge pull request #20 from mmiller42/greenkeeper/html-webpack-include-assets-plugin-1.0.0 Update html-webpack-include-assets-plugin to the latest version 🚀 |
9fe0983 |
mmiller42 | 3.5.1 |
Changed files
.circleci/config.yml
Show changes
@@ -43,8 +43,11 @@ jobs:
- deploy:
name: Publish
command: |
- if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
+ export TAG="v$(git log -1 --pretty=%B)"
+ if echo $TAG | grep "^v[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
npm publish
+ npm run build:scripts
+ node .circleci/lib/index.js
else
echo "No tag pushed, skipping deploy"
fi
➕ .circleci/scripts/createRelease.js
Show changes
@@ -0,0 +1,173 @@
+import 'babel-core/register'
+import 'babel-polyfill'
+
+import GitHubApi from 'github'
+import { render } from 'mustache'
+import { asc as sortVersions } from 'semver-sort'
+
+const TEMPLATE = \`
+# [What's New in {{newTag.name}}]({{{compareUrl}}})
+
+This is a summary of the differences between [{{newTag.name}}]({{{newTag.url}}}) and [{{previousTag.name}}]({{{previousTag.url}}}).
+
+## Commits
+
+<details>
+<summary><strong>Show commits</strong></summary>
+
+| SHA | Author | Message |
+| --- | ------ | ------- |
+{{#commits}}
+| [\\`{{{id}}}\\`]({{{url}}}) | [{{author.name}}]({{{author.url}}}) | {{{message}}} |
+{{/commits}}
+</details>
+
+## Changed files
+
+{{#files}}
+#### {{icon}} [\\`{{{filename}}}\\`]({{{url}}})
+
+{{#diff}}
+<details>
+<summary><strong>Show changes</strong></summary>
+
+\\`\\`\\`diff
+{{{.}}}
+\\`\\`\\`
+</details>
+{{/diff}}
+{{^diff}}
+*Inline diff not displayed. [View the whole file]({{{url}}})*
+{{/diff}}
+
+{{/files}}
+\`.trim()
+
+export const NO_PREVIOUS_RELEASE = new Error('No previous release found')
+
+export default async ({
+ token,
+ owner,
+ repo,
+ tag,
+ showDiff,
+ apiOptions = {},
+}) => {
+ const gitHub = new GitHubApi(apiOptions)
+ gitHub.authenticate({ type: 'oauth', token })
+
+ const { newTag, previousTag } = await fetchTags(gitHub, { owner, repo, tag })
+ const { compareUrl, commits, files } = await fetchDiff(gitHub, {
+ owner,
+ repo,
+ newTag,
+ previousTag,
+ })
+ const body = await renderBody({
+ owner,
+ repo,
+ showDiff,
+ newTag,
+ previousTag,
+ compareUrl,
+ commits,
+ files,
+ })
+
+ return await createRelease(gitHub, { owner, repo, newTag, body })
+}
+
+const fetchTags = async (gitHub, { owner, repo, tag }) => {
+ const { data } = await gitHub.gitdata.getTags({ owner, repo })
+ const tags = sortVersions(data.map(_tag => _tag.ref.split('/').pop()))
+
+ const newTagIndex = tags.findIndex(_tag => _tag === tag)
+
+ if (newTagIndex < 0) {
+ throw new Error(\`Could not find tag ${tag}\`)
+ }
+
+ if (newTagIndex === 0) {
+ throw NO_PREVIOUS_RELEASE
+ }
+
+ return {
+ newTag: tags[newTagIndex],
+ previousTag: tags[newTagIndex - 1],
+ }
+}
+
+const fetchDiff = async (gitHub, { owner, repo, newTag, previousTag }) => {
+ const { data } = await gitHub.repos.compareCommits({
+ owner,
+ repo,
+ base: previousTag,
+ head: newTag,
+ })
+ return {
+ compareUrl: data.html_url,
+ commits: data.commits.map(commit => ({
+ id: commit.sha.substr(0, 7),
+ url: commit.html_url,
+ author: {
+ name: commit.author.login,
+ url: commit.author.html_url,
+ },
+ message: commit.commit.message,
+ })),
+ files: data.files.map(file => ({
+ filename: file.filename,
+ url: file.blob_url,
+ status: file.status,
+ diff: file.patch || null,
+ })),
+ }
+}
+
+const renderBody = async ({
+ owner,
+ repo,
+ showDiff = () => true,
+ newTag,
+ previousTag,
+ compareUrl,
+ commits,
+ files,
+}) =>
+ render(TEMPLATE, {
+ compareUrl,
+ newTag: {
+ name: newTag,
+ url: \`https://github.com/${owner}/${repo}/tree/${newTag}\`,
+ },
+ previousTag: {
+ name: previousTag,
+ url: \`https://github.com/${owner}/${repo}/tree/${previousTag}\`,
+ },
+ commits: commits.map(commit => ({
+ ...commit,
+ message: commit.message.replace(/[\r\n]+/g, '<br>'),
+ })),
+ files: files.map(file => ({
+ ...file,
+ diff: file.diff && showDiff(file) && file.diff.replace(/\`/g, '\\\`'),
+ })),
+ icon() {
+ return {
+ added: ':heavy_plus_sign:',
+ modified: '',
+ removed: ':heavy_minus_sign:',
+ }[this.status]
+ },
+ })
+
+const createRelease = async (gitHub, { owner, repo, newTag, body }) => {
+ const { data } = await gitHub.repos.createRelease({
+ owner,
+ repo,
+ tag_name: newTag,
+ name: newTag,
+ body,
+ })
+ return data.html_url
+}
➕ .circleci/scripts/index.js
Show changes
@@ -0,0 +1,28 @@
+import createRelease from './createRelease'
+
+process.on('unhandledRejection', err => {
+ throw err
+})
+
+const {
+ CIRCLE_PROJECT_USERNAME: OWNER,
+ CIRCLE_PROJECT_REPONAME: REPO,
+ GH_TOKEN: TOKEN,
+ TAG,
+} = process.env
+
+createRelease({
+ token: TOKEN,
+ owner: OWNER,
+ repo: REPO,
+ tag: TAG,
+ showDiff: file => file.filename !== 'package-lock.json',
+})
+ .then(url => console.log(\`Release ${TAG} published at ${url}\`))
+ .catch(err => {
+ if (err === createRelease.NO_PREVIOUS_RELEASE) {
+ console.warn(err)
+ } else {
+ throw err
+ }
+ })
package-lock.json
Inline diff not displayed. View the whole file
package.json
Show changes
@@ -1,19 +1,24 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.5.0",
- "description":
- "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
- "keywords": ["htmlwebpackplugin", "webpack", "html", "externals"],
+ "version": "3.5.1",
+ "description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
+ "keywords": [
+ "htmlwebpackplugin",
+ "webpack",
+ "html",
+ "externals"
+ ],
"main": "lib/index.js",
"scripts": {
"precommit": "lint-staged",
"test": "mocha --require babel-register",
"build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files",
+ "build:scripts": "rm -rf .circleci/lib && babel .circleci/scripts --out-dir .circleci/lib --source-maps",
"watch": "npm run build -- --watch"
},
"lint-staged": {
- "*.{js,json}": [
- "prettier --write --no-semi --single-quote --trailing-comma es5 '{src/**/*.{js,json},test/**/*.js,*.json}'",
+ "{src,test,.circleci/scripts}.{js,json}": [
+ "prettier --write --no-semi --single-quote --trailing-comma es5",
"git add"
]
},
@@ -29,28 +34,31 @@
"bugs": {
"url": "https://github.com/mmiller42/html-webpack-externals-plugin/issues"
},
- "homepage":
- "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
+ "homepage": "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
"devDependencies": {
"assertion-error": "^1.0.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-o...
v3.5.0
What's New in v3.5.0
This is a summary of the differences between v3.5.0 and v3.4.0.
Commits
Show commits
SHA | Author | Message |
---|---|---|
75d8388 |
greenkeeper[bot] | fix(package): update html-webpack-include-assets-plugin to version 0.0.8 |
31031ff |
mmiller42 | Fix compatibility bug |
8bc4e6b |
mmiller42 | Compat fix 2 |
f8a135a |
mmiller42 | Updating package and lockfile |
3ab6c3d |
mmiller42 | Merge pull request #19 from mmiller42/greenkeeper/html-webpack-include-assets-plugin-0.0.8 Update html-webpack-include-assets-plugin to the latest version 🚀 |
c0abdbc |
mmiller42 | 3.5.0 |
Changed files
package-lock.json
Inline diff not displayed. View the whole file
package.json
Show changes
@@ -1,7 +1,8 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.4.0",
- "description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
+ "version": "3.5.0",
+ "description":
+ "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
"keywords": ["htmlwebpackplugin", "webpack", "html", "externals"],
"main": "lib/index.js",
"scripts": {
@@ -28,7 +29,8 @@
"bugs": {
"url": "https://github.com/mmiller42/html-webpack-externals-plugin/issues"
},
- "homepage": "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
+ "homepage":
+ "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
"devDependencies": {
"assertion-error": "^1.0.2",
"babel-cli": "^6.24.1",
@@ -57,6 +59,6 @@
"dependencies": {
"ajv": "^5.2.2",
"copy-webpack-plugin": "^4.0.1",
- "html-webpack-include-assets-plugin": "0.0.7"
+ "html-webpack-include-assets-plugin": "0.0.8"
}
}
src/HtmlWebpackExternalsPlugin.js
Show changes
@@ -39,7 +39,7 @@ export default class HtmlWebpackExternalsPlugin {
const entries = (Array.isArray(entry) ? entry : [entry]).map(entry => {
if (typeof entry === 'string') {
- entry = { path: entry, type: null }
+ entry = { path: entry, type: undefined }
}
if (HtmlWebpackExternalsPlugin.URL_ENTRY.test(entry.path)) {
return entry
@@ -115,7 +115,7 @@ export default class HtmlWebpackExternalsPlugin {
),
append,
hash: this.hash,
- files: this.files,
+ files: this.files == null ? undefined : this.files,
publicPath: '',
})
)
v3.4.0
What's New in v3.4.0
This is a summary of the differences between v3.4.0 and v3.3.5.
Commits
Show commits
SHA | Author | Message |
---|---|---|
1f68e25 |
mmiller42 | space indent |
42ff13e |
mmiller42 | Run prettier when anything changes; remove build before packing since it's already done on CI |
5562075 |
greenkeeper[bot] | docs(readme): add Greenkeeper badge |
cdb8ec6 |
mmiller42 | Merge pull request #15 from mmiller42/greenkeeper/initial Add Greenkeeper badge 🌴 |
e5abaae |
mmiller42 | Update README.md |
b21a14a |
mmiller42 | Add lockfile updating via Greenkeeper |
eecf37b |
mmiller42 | Merge remote-tracking branch 'origin/master' |
066724a |
mmiller42 | sudoit |
dbcb974 |
mmiller42 | Retriggering CircleCI |
fa54398 |
mmiller42 | Anal-retentive syntax fix |
62ad9c6 |
mmiller42 | Add an enabled option |
231ca52 |
mmiller42 | 3.4.0 |
Changed files
.circleci/config.yml
Show changes
@@ -16,11 +16,17 @@ jobs:
npm install npm@latest --no-save &&
sudo rm -rf /usr/local/lib/node_modules/npm &&
sudo mv node_modules/npm /usr/local/lib/node_modules/npm
+ - run:
+ name: Install greenkeeper-lockfile
+ command: sudo npm install -g greenkeeper-lockfile@1
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: npm install
+ - run:
+ name: Update lockfile
+ command: greenkeeper-lockfile-update
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
@@ -31,6 +37,9 @@ jobs:
- run:
name: Test
command: npm test
+ - run:
+ name: Upload lockfile
+ command: greenkeeper-lockfile-upload
- deploy:
name: Publish
command: |
README.md
Show changes
@@ -1,4 +1,4 @@
-# html-webpack-externals-plugin [![CircleCI](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin.svg?style=svg)](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin)
+# html-webpack-externals-plugin [![CircleCI](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin.svg?style=svg)](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin) [![Greenkeeper badge](https://badges.greenkeeper.io/mmiller42/html-webpack-externals-plugin.svg)](https://greenkeeper.io/)
Webpack plugin that works alongside [\`html-webpack-plugin\`](https://github.com/jantimon/html-webpack-plugin) to use pre-packaged vendor bundles.
@@ -31,7 +31,7 @@ plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackExternalsPlugin(
// See API section
- )
+ ),
]
\`\`\`
@@ -51,6 +51,7 @@ The constructor takes a configuration object with the following properties.
| \`outputPath\` | string | The path (relative to your Webpack \`outputPath\`) to store externals copied over by this plugin. | \`vendor\` |
| \`publicPath\` | string \| null | Override Webpack config's \`publicPath\` for the externals files, or \`null\` to use the default \`output.publicPath\` value. | \`null\` |
| \`files\` | string \| array<string> \| null | If you have multiple instances of HtmlWebpackPlugin, use this to specify globs of which files you want to inject assets into. Will add assets to all files by default. | \`null\` |
+| \`enabled\` | boolean | Set to \`false\` to disable the plugin (useful for disabling in development mode). | \`true\` |
## Examples
@@ -285,3 +286,20 @@ new HtmlWebpackExternalsPlugin({
files: ['about.html'],
})
\`\`\`
+
+### Disabling the plugin
+
+Sometimes you only want the plugin to be activated in certain environments. Rather than create separate Webpack configs or mess with splicing the plugins array, simply set the \`enabled\` option to \`false\` to disable the externals plugin entirely.
+
+\`\`\`js
+new HtmlWebpackExternalsPlugin({
+ externals: [
+ {
+ module: 'jquery',
+ entry: 'dist/jquery.min.js',
+ global: 'jQuery',
+ },
+ ],
+ enabled: process.env.NODE_ENV === 'production',
+})
+\`\`\`
package-lock.json
Inline diff not displayed. View the whole file
package.json
Show changes
@@ -1,23 +1,17 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.3.5",
+ "version": "3.4.0",
"description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
- "keywords": [
- "htmlwebpackplugin",
- "webpack",
- "html",
- "externals"
- ],
+ "keywords": ["htmlwebpackplugin", "webpack", "html", "externals"],
"main": "lib/index.js",
"scripts": {
- "prepack": "npm run build",
"precommit": "lint-staged",
"test": "mocha --require babel-register",
"build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files",
"watch": "npm run build -- --watch"
},
"lint-staged": {
- "*.js": [
+ "*.{js,json}": [
"prettier --write --no-semi --single-quote --trailing-comma es5 '{src/**/*.{js,json},test/**/*.js,*.json}'",
"git add"
]
@@ -36,6 +30,7 @@
},
"homepage": "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
"devDependencies": {
+ "assertion-error": "^1.0.2",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-plugin-add-module-exports": "^0.2.1",
src/HtmlWebpackExternalsPlugin.js
Show changes
@@ -25,11 +25,12 @@ export default class HtmlWebpackExternalsPlugin {
this.assetsToCopy = []
this.externals = {}
- const { externals, hash, outputPath, publicPath, files } = config
+ const { externals, hash, outputPath, publicPath, files, enabled } = config
this.hash = hash
this.outputPath = outputPath
this.publicPath = publicPath
this.files = files
+ this.enabled = enabled
externals.forEach(({ module, entry, global, supplements, append }) => {
this.externals[module] = global
@@ -63,6 +64,10 @@ export default class HtmlWebpackExternalsPlugin {
}
apply(compiler) {
+ if (!this.enabled) {
+ return
+ }
+
if (!compiler.options.externals) {
compiler.options.externals = this.externals
} else if (Array.isArray(compiler.options.externals)) {
src/configSchema.json
Show changes
@@ -75,6 +75,10 @@
},
"minItems": 1,
"default": null
+ },
+ "enabled": {
+ "type": "boolean",
+ "default": true
}
},
"required": ["externals"]
test/HtmlWebpackExternalsPlugin.spec.js
<d...
v3.3.5
What's New in v3.3.5
This is a summary of the differences between v3.3.5 and v3.3.4.
Commits
Show commits
SHA | Author | Message |
---|---|---|
438ae30 |
mmiller42 | CircleCI setup |
67a24b4 |
mmiller42 | CircleCI setup |
6b159ec |
mmiller42 | Naming steps |
73386cd |
mmiller42 | Trying to fix semver bug? |
c934e78 |
mmiller42 | Trying to fix semver bug? |
02dd50a |
mmiller42 | sudoit |
35af31d |
mmiller42 | build step |
0d68b81 |
mmiller42 | testing tests! |
bc01e19 |
mmiller42 | Unit test coverage! And some bugs I fixed along the way. |
1906e18 |
mmiller42 | Add publish configuration and CI badge |
2321037 |
mmiller42 | 3.3.5 |
07fa240 |
mmiller42 | Publish based on commit message instead of tag, since tags aren't supported in CircleCI 2.0 |
6a59200 |
mmiller42 | reversing version manually |
a787f60 |
mmiller42 | 3.3.5 |
Changed files
➕ .circleci/config.yml
Show changes
@@ -0,0 +1,41 @@
+version: 2
+jobs:
+ build:
+ docker:
+ - image: circleci/node:latest
+ working_directory: ~/html-webpack-externals-plugin
+
+ steps:
+ - checkout
+ - run:
+ name: Authenticate to npm registry
+ command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
+ - run:
+ name: Update npm
+ command: |
+ npm install npm@latest --no-save &&
+ sudo rm -rf /usr/local/lib/node_modules/npm &&
+ sudo mv node_modules/npm /usr/local/lib/node_modules/npm
+ - restore_cache:
+ key: dependency-cache-{{ checksum "package.json" }}
+ - run:
+ name: Install dependencies
+ command: npm install
+ - save_cache:
+ key: dependency-cache-{{ checksum "package.json" }}
+ paths:
+ - node_modules
+ - run:
+ name: Build
+ command: npm run build
+ - run:
+ name: Test
+ command: npm test
+ - deploy:
+ name: Publish
+ command: |
+ if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
+ npm publish
+ else
+ echo "No tag pushed, skipping deploy"
+ fi
.gitignore
Show changes
@@ -6,11 +6,14 @@
# Dependencies
node_modules
-
+˚
# Logs
*.log
.node_repl_history
.node_history
# Build files
lib
+
+# Temporary files
+tmp
.npmignore
Show changes
@@ -11,3 +11,6 @@ node_modules
*.log
.node_repl_history
.node_history
+
+# Temporary files
+tmp
README.md
Show changes
@@ -1,4 +1,4 @@
-# html-webpack-externals-plugin
+# html-webpack-externals-plugin [![CircleCI](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin.svg?style=svg)](https://circleci.com/gh/mmiller42/html-webpack-externals-plugin)
Webpack plugin that works alongside [\`html-webpack-plugin\`](https://github.com/jantimon/html-webpack-plugin) to use pre-packaged vendor bundles.
@@ -251,7 +251,7 @@ You should include a trailing slash in your public path, and a leading slash if
This example assumes \`bootstrap\` is installed in the app. It:
1. copies \`node_modules/bootstrap/dist/css/bootstrap.min.css\` to \`<output path>/vendor/bootstrap/dist/css/bootstrap.min.css\`
-1. adds \`<link href="/public/vendor/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">\` to your HTML file, before your chunks
+1. adds \`<link href="/assets/vendor/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">\` to your HTML file, before your chunks
\`\`\`js
new HtmlWebpackExternalsPlugin({
package-lock.json
Inline diff not displayed. View the whole file
package.json
Show changes
@@ -1,6 +1,6 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.3.4",
+ "version": "3.3.5",
"description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
"keywords": [
"htmlwebpackplugin",
@@ -12,12 +12,13 @@
"scripts": {
"prepack": "npm run build",
"precommit": "lint-staged",
+ "test": "mocha --require babel-register",
"build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files",
"watch": "npm run build -- --watch"
},
"lint-staged": {
"*.js": [
- "prettier --write --no-semi --single-quote --trailing-comma es5 '{src/**/*.{js,json},*.json}'",
+ "prettier --write --no-semi --single-quote --trailing-comma es5 '{src/**/*.{js,json},test/**/*.js,*.json}'",
"git add"
]
},
@@ -41,9 +42,19 @@
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.6.0",
+ "babel-register": "^6.24.1",
+ "bootstrap": "^3.3.7",
+ "css-loader": "^0.28.4",
+ "escape-string-regexp": "^1.0.5",
+ "extract-text-webpack-plugin": "^3.0.0",
+ "html-webpack-plugin": "^2.0.0",
"husky": "^0.14.3",
- "lint-staged": "^4.0.1",
- "prettier": "^1.5.3"
+ "jquery": "^3.2.1",
+ "lint-staged": "^4.0.2",
+ "mocha": "^3.4.2",
+ "prettier": "^1.5.3",
+ "rimraf": "^2.6.1",
+ "webpack": "^3.3.0"
},
"peerDependencies": {
"html-webpack-plugin": "^2.0.0"
src/HtmlWebpackExternalsPlugin.js
Show changes
@@ -74,10 +74,15 @@ export default class HtmlWebpackExternalsPlugin {
}
}
- const publicPath =
- this.publicPath == null
- ? compiler.options.output.publicPath
- : this.publicPath
+ const publicPath = (() => {
+ if (this.publicPath != null) {
+ return this.publicPath
+ } else if (compiler.options.output.publicPath != null) {
+ return compiler.options.output.publicPath
+ } else {
+ return ''
+ }
+ })()
const pluginsToApply = []
➕ test/HtmlWebpackExternalsPlugin.spec.js
Show changes
@@ -0,0 +1,298 @@
+import assert from 'assert'
+import HtmlWebpackPlugin from 'html-webpack-plugin'
+import HtmlWebpackExternalsPlugin from '../lib/'
+import {
+ cleanUp,
+ runWebpa...
v3.3.4
What's New in v3.3.4
This is a summary of the differences between v3.3.4 and v3.3.3.
Commits
Show commits
SHA | Author | Message |
---|---|---|
ec53bce |
mmiller42 | Remove webpack peerDependency (we can rely on html-webpack-plugin's peerDependency instead) |
2862e15 |
mmiller42 | 3.3.4 |
Changed files
package-lock.json
Inline diff not displayed. View the whole file
package.json
Show changes
@@ -1,6 +1,6 @@
{
"name": "html-webpack-externals-plugin",
- "version": "3.3.3",
+ "version": "3.3.4",
"description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
"keywords": [
"htmlwebpackplugin",
@@ -46,8 +46,7 @@
"prettier": "^1.5.3"
},
"peerDependencies": {
- "html-webpack-plugin": "^2.0.0",
- "webpack": "^2.0.0"
+ "html-webpack-plugin": "^2.0.0"
},
"dependencies": {
"ajv": "^5.2.2",