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.2.0 to 0.3.0

.idea/codeStyleSettings.xml

6

CHANGELOG.md
# CHANGELOG
## 0.3.0
- Added support for prefix in search queries
## 0.2.0
- Add support for globbing of file paths
- Added support for globbing of file paths

@@ -6,32 +6,35 @@ var path = require('path');

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 ? requireManifests(query.manifestPath) : false);
var prefix = query.prefix || '';
if (manifest) {
for (var key in manifest) {
var value = manifest[key];
var pattern = new RegExp(key, 'gm');
source = source.replace(pattern, value);
if (manifest) {
for (var key in manifest) {
if (manifest.hasOwnProperty(key)) {
var value = manifest[key];
var pattern = new RegExp(prefix + 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);
}, {});
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);
}, {});
}
function requireManifest(manifestPath) {
try {
return require(path.resolve(process.cwd(), manifestPath));
} catch (error) {
return false;
}
try {
return require(path.resolve(process.cwd(), manifestPath));
} catch (error) {
return false;
}
}
{
"name": "rev-replace-loader",
"version": "0.2.0",
"version": "0.3.0",
"description": "Webpack loader to replace asset paths with hashed ones from a rev-manifest.json file",

@@ -8,3 +8,3 @@ "main": "index.js",

"type": "git",
"url": "git://github.com/vigetlabs/rev-replace-loader.git"
"url": "git://github.com/bushee/rev-replace-loader.git"
},

@@ -11,0 +11,0 @@ "keywords": [

@@ -25,16 +25,19 @@ Replace rev'd asset references in your production JS compiled with Webpack!

There is optional `prefix` parameter - if given, it will be prepended to all queries to be replaced.
```js
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'rev-replace',
query: {
manifest: require('path/to/manifest'),
manifestPath: 'path/to/manifest'
}
}
]
}
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'rev-replace',
query: {
manifest: require('path/to/manifest'),
manifestPath: 'path/to/manifest',
prefix: '/'
}
}
]
}
}
```
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