Skip to content

Commit 39987ad

Browse files
committed
Realese 1.1.3
1 parent bad217b commit 39987ad

File tree

6 files changed

+29
-6
lines changed

6 files changed

+29
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.1.3
2+
3+
+ add support relative paths for output
4+
15
# 1.1.2
26

37
+ changed output key to encoded html string in stats file

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ plugins: [
120120
// Prefix for file names
121121
prefix: '/assets/icons-[hash:8]/', // default '/'
122122
// Output path for icons (icons will be saved to output.path(webpack config) + this key)
123-
output: '/icons-[hash:8]/', // default '/'
123+
output: '/icons-[hash:8]/', // default '/'. Can be absolute or relative
124124
// Emit all stats of the generated icons
125125
emitStats: false,
126126
// The name of the json containing all favicon information
@@ -202,6 +202,18 @@ but files will be saved to `/icons-4b62aad7/` directory and you `iconstats.json`
202202

203203
#### Keep in mind what `prefix` change filenames inside html, `output` it is the path where icons wiil be saved
204204

205+
#### Or another case. You want save icons above the directory of webpack `output` and want set corrent path in the manifest files and html files
206+
207+
```javascript
208+
new AppManifestWebpackPlugin({
209+
// Your source logo
210+
logo: 'my-logo.png',
211+
// Output path can be relative. Icons will be saved to webpack output directory + output
212+
output: '../icons/',
213+
// Change prefix of files for correct paths in your html and manifest files
214+
prefix: '/icons/'
215+
})
216+
```
205217

206218
Stats file
207219
-----------

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const path = require('path')
55

66
const DEFAULT_OPTIONS = {
77
emitStats: false,
8+
prefix: '',
9+
output: '/',
810
statsFilename: 'iconstats-[hash].json',
911
persistentCache: true,
1012
inject: true,

lib/compiler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ function getEntry(options, context) {
2323
require.resolve('./favicons.js') +
2424
'?' +
2525
JSON.stringify({
26-
outputFilePrefix: options.prefix || '',
27-
outputFilesDir: options.output || '/',
26+
outputFilePrefix: options.prefix,
27+
outputFilesDir: options.output,
2828
persistentCache: options.persistentCache,
2929
statsEncodeHtml: options.statsEncodeHtml,
3030
config: options.config,

lib/favicons.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const loaderUtils = require('loader-utils')
22
const favicons = require('favicons')
33
const faviconPersitenceCache = require('./cache')
4+
const path = require('path')
45

56
module.exports = function(content) {
67
const self = this
@@ -54,7 +55,11 @@ module.exports = function(content) {
5455
function generateIcons(loader, imageFileStream, outputDir, query, callback) {
5556
const pathPrefix = query.outputFilePrefix.replace(/\/$/, '')
5657

57-
query.config.path = pathPrefix + outputDir
58+
if (!path.isAbsolute(outputDir)) {
59+
query.config.path = pathPrefix
60+
} else {
61+
query.config.path = pathPrefix + outputDir
62+
}
5863

5964
favicons(imageFileStream, query.config, (err, response) => {
6065
if (err) return callback(err)
@@ -73,7 +78,7 @@ function generateIcons(loader, imageFileStream, outputDir, query, callback) {
7378
})
7479

7580
let returnData = {
76-
outputFilePrefix: pathPrefix + outputDir,
81+
outputFilePrefix: query.config.path,
7782
html: response.html,
7883
files: fileNames,
7984
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "app-manifest-webpack-plugin",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Let webpack generate manifest files, all your favicons and icons for you",
55
"author": "Roman Olin <[email protected]> (https://github.com/romanlex)",
66
"repository": {

0 commit comments

Comments
 (0)