html-webpack-plugin 4.0.0-beta.4 → 4.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -205,11 +205,13 @@ your own template. The easiest way is to use the `template` option and pass a cu
205
205
  The html-webpack-plugin will automatically inject all necessary CSS, JS, manifest
206
206
  and favicon files into the markup.
207
207
 
208
+ Details of other template loaders are [documented here](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md).
209
+
208
210
  ```js
209
211
  plugins: [
210
212
  new HtmlWebpackPlugin({
211
213
  title: 'Custom template',
212
- // Load a custom template (lodash by default see the FAQ for details)
214
+ // Load a custom template (lodash by default)
213
215
  template: 'index.html'
214
216
  })
215
217
  ]
@@ -354,10 +356,12 @@ To add those use a key/value pair:
354
356
  ```js
355
357
  plugins: [
356
358
  new HtmlWebpackPlugin({
357
- 'viewport': 'width=device-width, initial-scale=1, shrink-to-fit=no',
358
- // Will generate: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
359
- 'theme-color': '#4285f4'
360
- // Will generate: <meta name="theme-color" content="#4285f4">
359
+ 'meta': {
360
+ 'viewport': 'width=device-width, initial-scale=1, shrink-to-fit=no',
361
+ // Will generate: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
362
+ 'theme-color': '#4285f4'
363
+ // Will generate: <meta name="theme-color" content="#4285f4">
364
+ }
361
365
  })
362
366
  ]
363
367
  ```
package/index.js CHANGED
@@ -524,21 +524,6 @@ class HtmlWebpackPlugin {
524
524
  return assets.js.length && assets.js.every((assetPath) => /\.hot-update\.js$/.test(assetPath));
525
525
  }
526
526
 
527
- /**
528
- * Return true if PATH is an absolute url path, otherwise false
529
- *
530
- * @param {string | undefined} path
531
- */
532
- isAbsolutePath (path) {
533
- if (typeof path === 'undefined' || path === '') return false;
534
- // If the path start with '/'
535
- if (path.indexOf('/') === 0) return true;
536
- // If the path contain the '://' scheme
537
- if (path.indexOf('://') !== -1) return true;
538
-
539
- return false;
540
- }
541
-
542
527
  /**
543
528
  * The htmlWebpackPluginAssets extracts the asset information of a webpack compilation
544
529
  * for all given entry names
@@ -557,13 +542,15 @@ class HtmlWebpackPlugin {
557
542
 
558
543
  /**
559
544
  * @type {string} the configured public path to the asset root
560
- * if the absolute path publicPath is set in the current webpack config use it otherwise
545
+ * if a path publicPath is set in the current webpack config use it otherwise
561
546
  * fallback to a realtive path
562
547
  */
563
- let publicPath = this.isAbsolutePath(compilation.options.output.publicPath)
564
- // If the absolute path is set in the publicPath use it
565
- ? compilation.mainTemplate.getPublicPath({hash: compilationHash})
566
- // If publicPath was a relative path get the realtive path
548
+ const webpackPublicPath = compilation.mainTemplate.getPublicPath({hash: compilationHash});
549
+ const isPublicPathDefined = webpackPublicPath.trim() !== '';
550
+ let publicPath = isPublicPathDefined
551
+ // If a hard coded public path exists use it
552
+ ? webpackPublicPath
553
+ // If no public path was set get a relative url path
567
554
  : path.relative(path.resolve(compilation.options.output.path, path.dirname(childCompilationOutputName)), compilation.options.output.path)
568
555
  .split(path.sep).join('/');
569
556
 
package/lib/compiler.js CHANGED
@@ -119,18 +119,6 @@ class HtmlWebpackChildCompiler {
119
119
  new LibraryTemplatePlugin('HTML_WEBPACK_PLUGIN_RESULT', 'var').apply(childCompiler);
120
120
  new LoaderTargetPlugin('node').apply(childCompiler);
121
121
 
122
- // Fix for "Uncaught TypeError: __webpack_require__(...) is not a function"
123
- // Hot module replacement requires that every child compiler has its own
124
- // cache. @see https://github.com/ampedandwired/html-webpack-plugin/pull/179
125
- childCompiler.hooks.compilation.tap('HtmlWebpackPlugin', compilation => {
126
- if (compilation.cache) {
127
- if (!compilation.cache[compilerName]) {
128
- compilation.cache[compilerName] = {};
129
- }
130
- compilation.cache = compilation.cache[compilerName];
131
- }
132
- });
133
-
134
122
  // Add all templates
135
123
  this.templates.forEach((template, index) => {
136
124
  new SingleEntryPlugin(childCompiler.context, template, `HtmlWebpackPlugin_${index}`).apply(childCompiler);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.5",
4
4
  "license": "MIT",
5
5
  "description": "Simplifies creation of HTML files to serve your webpack bundles",
6
6
  "author": "Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)",