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

less-plugin-resolve

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

less-plugin-resolve - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

68

index.js
const enhancedResolve = require("enhanced-resolve");
const path = require("path");

@@ -44,3 +45,3 @@ /* eslint-disable class-methods-use-this */

install(less, pluginManager) {
const { aliases } = this.options;
const { aliases, urlRewriteTargetPath } = this.options;

@@ -70,10 +71,10 @@ const resolver = enhancedResolve.create({

}
if (this.isPathAbsolute(filename)) {
return false;
}
return true;
}
// Sync resolving is used at least by the `data-uri` function.

@@ -105,3 +106,3 @@ // This file manager doesn't know how to do it, so let's delegate it

}
async resolveRequests(context, possibleRequests) {

@@ -111,5 +112,5 @@ if (possibleRequests.length === 0) {

}
let result;
try {

@@ -126,18 +127,18 @@ result = await resolve(context, possibleRequests[0]);

}
return result;
}
async loadFile(filename, ...args) {
let result;
try {
if (IS_SPECIAL_MODULE_IMPORT.test(filename)) {
const error = new Error();
error.type = "Next";
throw error;
}
result = await super.loadFile(filename, ...args);

@@ -148,3 +149,3 @@ } catch (error) {

}
try {

@@ -157,14 +158,45 @@ result = await this.resolveFilename(filename, ...args);

`Enhanced resolver error missing:\n${webpackResolveError.missing}\n\n`;
return Promise.reject(error);
}
return super.loadFile(result, ...args);
}
return result;
}
}
class UrlVisitor {
constructor(options) {
this.isReplacing = true;
this.isPreEvalVisitor = true;
this._options = options;
this._visitor = new less.visitors.Visitor(this);
}
run(root) {
return this._visitor.visit(root);
}
visitUrl(node, _visitArgs) {
const isRelative = node.value.value.startsWith('./') || node.value.value.startsWith('../');
if (isRelative) {
const filename = node._fileInfo && node._fileInfo.filename
if (filename) {
const assetPath = path.resolve(path.dirname(filename), node.value.value);
const relativePath = path.relative(
path.dirname(urlRewriteTargetPath),
assetPath
);
node.value.value = relativePath
}
}
return node
}
}
pluginManager.addFileManager(new ResolvedFileManager());
if (urlRewriteTargetPath) {
pluginManager.addVisitor(new UrlVisitor());
}
}

@@ -171,0 +203,0 @@ }

{
"name": "less-plugin-resolve",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.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