You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
478 B
24 lines
478 B
const { dirname, resolve } = require("path"); |
|
const { existsSync } = require("fs"); |
|
|
|
module.exports = function resolveId(file, url, opts) { |
|
if (opts.paths && opts.paths.length) { |
|
let absolutePath; |
|
|
|
for (let path of opts.paths) { |
|
absolutePath = resolve(path, url); |
|
|
|
if (existsSync(absolutePath)) { |
|
return absolutePath; |
|
} |
|
} |
|
|
|
return absolutePath; |
|
} |
|
|
|
if (file) { |
|
return resolve(dirname(file), url); |
|
} |
|
|
|
return resolve(url); |
|
};
|
|
|