This repository was archived by the owner on Apr 5, 2021. It is now read-only.
v3.2.0
What's New in v3.2.0
This is a summary of the differences between v3.2.0 and v3.1.0.
Commits
Show commits
| SHA | Author | Message |
|---|---|---|
80a02ad |
mmiller42 | check off list |
59f3bcb |
mmiller42 | Use JSON schema defaults instead to normalize config |
30d1a13 |
mmiller42 | delete roadmap |
4e52510 |
mmiller42 | Add files option |
0c95681 |
mmiller42 | 3.2.0 |
Changed files
README.md
Show changes
@@ -50,6 +50,7 @@ The constructor takes a configuration object with the following properties.
| \`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\` |
| \`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\` |
## Example
➖ ROADMAP.md
Show changes
@@ -1,7 +0,0 @@
-# v3.0.0 Roadmap
-
-* [ ] Support CDNs in addition to copying local modules to the build
-* [ ] Support ways to manually specify asset type (e.g. for when URLs don't end in \`.css\` or \`.js\`) -- may be dependent on html-webpack-include-assets-plugin
-* [ ] Allow more flexibility in how files are copied to the public output via copy-webpack-plugin
-* [x] Allow overriding of output \`publicPath\`
-* [ ] Support specifying which HTML files are affected by the plugin in the case of multiple instances of html-webpack-pluginpackage-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.1.0",
+ "version": "3.2.0",
"description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
"keywords": [
"htmlwebpackplugin",src/HtmlWebpackExternalsPlugin.js
Show changes
@@ -4,7 +4,7 @@ import Ajv from 'ajv'
export default class HtmlWebpackExternalsPlugin {
static validateArguments = (() => {
- const ajv = new Ajv()
+ const ajv = new Ajv({ useDefaults: true })
const validateConfig = ajv.compile({
type: 'object',
properties: {
@@ -19,20 +19,27 @@ export default class HtmlWebpackExternalsPlugin {
items: { type: 'string' },
minItems: 1,
},
- global: { type: ['string', 'null'] },
+ global: { type: ['string', 'null'], default: null },
supplements: {
type: 'array',
items: { type: 'string' },
+ default: [],
},
- append: { type: 'boolean' },
+ append: { type: 'boolean', default: false },
},
required: ['module', 'entry'],
},
minItems: 1,
},
- hash: { type: 'boolean' },
- outputPath: { type: 'string' },
- publicPath: { type: ['string', 'null'] },
+ hash: { type: 'boolean', default: false },
+ outputPath: { type: 'string', default: 'vendor' },
+ publicPath: { type: ['string', 'null'], default: null },
+ files: {
+ type: ['string', 'array', 'null'],
+ items: { type: 'string' },
+ minItems: 1,
+ default: null,
+ },
},
required: ['externals'],
})
@@ -54,44 +61,38 @@ export default class HtmlWebpackExternalsPlugin {
this.assetsToCopy = []
this.externals = {}
- const {
- externals,
- hash = false,
- outputPath = 'vendor',
- publicPath = null,
- } = config
+ const { externals, hash, outputPath, publicPath, files } = config
this.hash = hash
this.outputPath = outputPath
this.publicPath = publicPath
+ this.files = files
- externals.forEach(
- ({ module, entry, global = null, supplements = [], append = false }) => {
- this.externals[module] = global
-
- const localEntries = []
-
- const entries = (Array.isArray(entry) ? entry : [entry]).map(entry => {
- if (HtmlWebpackExternalsPlugin.URL_ENTRY.test(entry)) {
- return entry
- }
- const localEntry = \`${module}/${entry}\`
- localEntries.push(localEntry)
- return localEntry
- })
-
- if (append) {
- this.assetsToAppend = [...this.assetsToAppend, ...entries]
- } else {
- this.assetsToPrepend = [...this.assetsToPrepend, ...entries]
- }
+ externals.forEach(({ module, entry, global, supplements, append }) => {
+ this.externals[module] = global
+
+ const localEntries = []
- this.assetsToCopy = [
- ...this.assetsToCopy,
- ...localEntries,
- ...supplements.map(asset => \`${module}/${asset}\`),
- ]
+ const entries = (Array.isArray(entry) ? entry : [entry]).map(entry => {
+ if (HtmlWebpackExternalsPlugin.URL_ENTRY.test(entry)) {
+ return entry
+ }
+ const localEntry = \`${module}/${entry}\`
+ localEntries.push(localEntry)
+ return localEntry
+ })
+
+ if (append) {
+ this.assetsToAppend = [...this.assetsToAppend, ...entries]
+ } else {
+ this.assetsToPrepend = [...this.assetsToPrepend, ...entries]
}
- )
+
+ this.assetsToCopy = [
+ ...this.assetsToCopy,
+ ...localEntries,
+ ...supplements.map(asset => \`${module}/${asset}\`),
+ ]
+ })
}
apply(compiler) {
@@ -134,6 +135,7 @@ export default class HtmlWebpackExternalsPlugin {
),
append,
hash: this.hash,
+ files: this.files,
publicPath: '',
})
)