Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Add custom publicPath option #25

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ Presets of `options`:
start_url: ".",
inject: true,
fingerprints: true,
ios: false
ios: false,
publicPath: null
}
```

Expand All @@ -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.

Expand Down
7 changes: 4 additions & 3 deletions dist/WebpackPwaManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {
Expand All @@ -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);
});
}
Expand Down
7 changes: 4 additions & 3 deletions src/WebpackPwaManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = {
Expand All @@ -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)
})
}
Expand Down