diff --git a/CHANGELOG.md b/CHANGELOG.md index 25b3d9b..e19347f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # SaveRemoteFilePlugin webpack plugin Changelog +## 1.1.0 - 2020-03-29 +### Added +* Added 'hash' option to specify whether the plugin adds content hashes to output filenames. + ## 1.0.2 - 2018-10-22 ### Changed * Code and docs cleanup diff --git a/README.md b/README.md index 2e62384..188bb4c 100755 --- a/README.md +++ b/README.md @@ -44,5 +44,6 @@ This would emit `js/analytics.45eff9ff7d6c7c1e3c3d4184fdbbed90.js` and in your ` You can pass in either an object, or an array of objects for downloading multiple files. -* **url** remote URL of the remote file to save locally -* **filepath** filename where the file will be saved, relative to your webpack `output.path` +* **url** - remote URL of the remote file to save locally +* **filepath** - filename where the file will be saved, relative to your webpack `output.path` +* **hash** - [boolean] whether to add a content hash to the output filename. (default: `true`) diff --git a/dist/index.js b/dist/index.js index bfdf95e..957c1c0 100755 --- a/dist/index.js +++ b/dist/index.js @@ -39,7 +39,7 @@ module.exports = function () { var reportProgress = context && context.reportProgress; download(option.url).then(function (data) { var hash = crypto.createHash('md5').update(data).digest("hex"); - var newPath = _this.appendHashToPath(option.filepath, hash); + var newPath = option.hash === false ? option.filepath : _this.appendHashToPath(option.filepath, hash); compilation.assets[newPath] = { size: function size() { return data.length; diff --git a/package.json b/package.json index 2cf3a51..9513b69 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "save-remote-file-webpack-plugin", - "version": "1.0.2", + "version": "1.1.0", "description": "webpack 4 plugin to download & save remote files locally", "main": "dist/index.js", "dependencies": { diff --git a/src/index.js b/src/index.js index 2f7f9ee..c95472d 100755 --- a/src/index.js +++ b/src/index.js @@ -31,7 +31,7 @@ module.exports = class SaveRemoteFilePlugin { const reportProgress = context && context.reportProgress; download(option.url).then(data => { const hash = crypto.createHash('md5').update(data).digest("hex"); - const newPath = this.appendHashToPath(option.filepath, hash); + const newPath = (option.hash === false) ? option.filepath : this.appendHashToPath(option.filepath, hash); compilation.assets[newPath] = { size: () => data.length, source: () => data