diff --git a/README.md b/README.md index f2f74ef..e2ff061 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,8 @@ Presets of `options`: start_url: ".", inject: true, fingerprints: true, - ios: false + ios: false, + publicPath: null } ``` @@ -150,7 +151,7 @@ When `inject: true` and `ios: true`, specific Apple meta tags will be injected t } ``` -This plugin also supports the [Webpack's public path](https://webpack.js.org/configuration/output/#output-publicpath) definition. +If `publicPath` option is not given, this plugin fallbacks to [Webpack's public path](https://webpack.js.org/configuration/output/#output-publicpath) definition. When defining an icon object, you can also specify its output directory using a property called `destination`. Using `ios: true` in an icon object makes it eligible to the `apple-touch-icon` meta tag injection. Using `ios: 'startup'` in an icon object makes it eligible to the `apple-touch-startup-image` meta tag injection. diff --git a/dist/WebpackPwaManifest.js b/dist/WebpackPwaManifest.js index 1cc469a..d10c999 100644 --- a/dist/WebpackPwaManifest.js +++ b/dist/WebpackPwaManifest.js @@ -34,7 +34,8 @@ var WebpackPwaManifest = function () { start_url: '.', inject: true, fingerprints: true, - ios: false + ios: false, + publicPath: null }, options || {}); (0, _Versioning2.default)(this.options, 'useWebpackPublicPath'); this.options.short_name = this.options.short_name || this.options.name; @@ -49,7 +50,7 @@ var WebpackPwaManifest = function () { compiler.plugin('compilation', function (compilation) { compilation.plugin('html-webpack-plugin-before-html-processing', function (htmlPluginData, callback) { if (!_this.htmlPlugin) _this.htmlPlugin = true; - (0, _Injector.buildResources)(_this, compilation.options.output.publicPath, function () { + (0, _Injector.buildResources)(_this, _this.options.publicPath || compilation.options.output.publicPath, function () { if (_this.options.inject) { var tags = (0, _Injector.generateAppleTags)(_this.options, _this.assets); var themeColorTag = { @@ -71,7 +72,7 @@ var WebpackPwaManifest = function () { if (_this.htmlPlugin) { (0, _Injector.injectResources)(compilation, _this.assets, callback); } else { - (0, _Injector.buildResources)(_this, compilation.options.output.publicPath, function () { + (0, _Injector.buildResources)(_this, _this.options.publicPath || compilation.options.output.publicPath, function () { (0, _Injector.injectResources)(compilation, _this.assets, callback); }); } diff --git a/src/WebpackPwaManifest.js b/src/WebpackPwaManifest.js index 088a629..cb18fcf 100644 --- a/src/WebpackPwaManifest.js +++ b/src/WebpackPwaManifest.js @@ -15,7 +15,8 @@ class WebpackPwaManifest { start_url: '.', inject: true, fingerprints: true, - ios: false + ios: false, + publicPath: null }, options || {}) checkDeprecated(this.options, 'useWebpackPublicPath') this.options.short_name = this.options.short_name || this.options.name @@ -28,7 +29,7 @@ class WebpackPwaManifest { compiler.plugin('compilation', (compilation) => { compilation.plugin('html-webpack-plugin-before-html-processing', function (htmlPluginData, callback) { if (!_this.htmlPlugin) _this.htmlPlugin = true - buildResources(_this, compilation.options.output.publicPath, () => { + buildResources(_this, _this.options.publicPath || compilation.options.output.publicPath, () => { if (_this.options.inject) { const tags = generateAppleTags(_this.options, _this.assets) const themeColorTag = { @@ -53,7 +54,7 @@ class WebpackPwaManifest { if (_this.htmlPlugin) { injectResources(compilation, _this.assets, callback) } else { - buildResources(_this, compilation.options.output.publicPath, () => { + buildResources(_this, _this.options.publicPath || compilation.options.output.publicPath, () => { injectResources(compilation, _this.assets, callback) }) }