Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rev-replace-loader

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rev-replace-loader - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

CHANGELOG.md

38

index.js

@@ -1,18 +0,28 @@

var path = require('path')
var loaderUtils = require('loader-utils')
var path = require('path');
var glob = require('glob');
var loaderUtils = require('loader-utils');
module.exports = function(source) {
module.exports = function (source) {
var query = loaderUtils.parseQuery(this.query);
var manifest = query.manifest || (query.manifestPath ? requireManifests(query.manifestPath) : false);
var query = loaderUtils.parseQuery(this.query)
var manifest = query.manifest || (query.manifestPath ? requireManifest(query.manifestPath) : false)
if (manifest) {
for ( var key in manifest ) {
var value = manifest[key]
var pattern = new RegExp(key, 'gm')
source = source.replace(pattern, value)
for (var key in manifest) {
var value = manifest[key];
var pattern = new RegExp(key, 'gm');
source = source.replace(pattern, value);
}
}
return source
return source;
};
function requireManifests(manifestGlob) {
return glob.sync(manifestGlob).map(function (path) {
return requireManifest(path);
}).filter(function (manifest) {
return manifest !== false;
}).reduce(function (manifest, current) {
return Object.assign(manifest, current);
}, {});
}

@@ -22,6 +32,6 @@

try {
return require(manifestPath)
} catch(error) {
return false
return require(path.resolve(process.cwd(), manifestPath));
} catch (error) {
return false;
}
}
{
"name": "rev-replace-loader",
"version": "0.1.4",
"version": "0.2.0",
"description": "Webpack loader to replace asset paths with hashed ones from a rev-manifest.json file",

@@ -18,7 +18,7 @@ "main": "index.js",

],
"author": "Dan Tello",
"license": "MIT",
"dependencies": {
"glob": "7.1.2",
"loader-utils": "0.2.16"
}
}

@@ -23,2 +23,3 @@ Replace rev'd asset references in your production JS compiled with Webpack!

You can either pass a `manifest` object directly, or pass a `manfiestPath` for the loader to try. The latter will not error if no manifest file is found. Filenames will simply remain the same.
The `manifestPath` parameter also supports `glob` queries.

@@ -25,0 +26,0 @@ ```js

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc