rev-replace-loader
Advanced tools
Comparing version 0.3.0 to 0.4.0
# CHANGELOG | ||
## 0.4.0 | ||
- Caching manifests for faster future use | ||
## 0.3.0 | ||
@@ -4,0 +7,0 @@ - Added support for prefix in search queries |
22
index.js
@@ -7,3 +7,3 @@ var path = require('path'); | ||
var query = loaderUtils.parseQuery(this.query); | ||
var manifest = query.manifest || (query.manifestPath ? requireManifests(query.manifestPath) : false); | ||
var manifest = getManifest(query); | ||
var prefix = query.prefix || ''; | ||
@@ -24,2 +24,22 @@ | ||
var cache = { | ||
cached: {}, | ||
get: function (path) { | ||
if (!this.cached[path]) { | ||
this.cached[path] = requireManifests(path); | ||
} | ||
return this.cached[path]; | ||
} | ||
}; | ||
function getManifest(query) { | ||
if (query.manifest) { | ||
return query.manifest; | ||
} | ||
if (query.manifestPath) { | ||
return cache.get(query.manifestPath); | ||
} | ||
return false; | ||
} | ||
function requireManifests(manifestGlob) { | ||
@@ -26,0 +46,0 @@ return glob.sync(manifestGlob).map(function (path) { |
{ | ||
"name": "rev-replace-loader", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Webpack loader to replace asset paths with hashed ones from a rev-manifest.json file", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
46988
52
0