rollup-plugin-smart-asset
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -207,4 +207,8 @@ 'use strict'; | ||
const statAsync = util.promisify(fs.stat); | ||
const readFileAsync$1 = util.promisify(fs.readFile); | ||
const readFileAsync$1 = util.promisify(fs.readFile); // replace windows paths to unix paths on windows platform | ||
function slash(path) { | ||
return path.replace(/\\/g, "/"); | ||
} | ||
function markRelative(path) { | ||
@@ -224,3 +228,3 @@ if (path.substr(0, 3) === "../" || path.substr(0, 2) === "./" || path.substr(0, 1) === "/") { | ||
function getAssetPublicPath(assetName, publicPath) { | ||
return publicPath ? path.posix.join(publicPath, assetName) : assetName; | ||
return slash(publicPath ? path.join(publicPath, assetName) : assetName); | ||
} | ||
@@ -233,6 +237,6 @@ | ||
const assetRel = path.relative(path.dirname(wrapperFile), assetFile); | ||
return markRelative(path.posix.normalize(assetRel)); | ||
return markRelative(slash(path.normalize(assetRel))); | ||
} | ||
return markRelative(assetsPath ? path.posix.join(assetsPath, assetName) : assetName); | ||
return markRelative(slash(assetsPath ? path.join(assetsPath, assetName) : assetName)); | ||
} | ||
@@ -383,3 +387,3 @@ | ||
} else if (mode === "rebase") { | ||
const assetName = path.posix.relative(options.rebasePath, id); | ||
const assetName = path.relative(options.rebasePath, id); | ||
value = options.keepImport ? getAssetImportPath(assetName) : getAssetPublicPath(assetName, options.publicPath); | ||
@@ -386,0 +390,0 @@ } else { |
import { promisify } from 'util'; | ||
import { readFile, stat, copyFileSync } from 'fs'; | ||
import { posix, dirname, join, extname, relative, parse } from 'path'; | ||
import { join, relative, dirname, extname, normalize, parse } from 'path'; | ||
import { sync } from 'mkdirp'; | ||
@@ -203,4 +203,8 @@ import { getType } from 'mime'; | ||
const statAsync = promisify(stat); | ||
const readFileAsync$1 = promisify(readFile); | ||
const readFileAsync$1 = promisify(readFile); // replace windows paths to unix paths on windows platform | ||
function slash(path) { | ||
return path.replace(/\\/g, "/"); | ||
} | ||
function markRelative(path) { | ||
@@ -220,3 +224,3 @@ if (path.substr(0, 3) === "../" || path.substr(0, 2) === "./" || path.substr(0, 1) === "/") { | ||
function getAssetPublicPath(assetName, publicPath) { | ||
return publicPath ? posix.join(publicPath, assetName) : assetName; | ||
return slash(publicPath ? join(publicPath, assetName) : assetName); | ||
} | ||
@@ -229,6 +233,6 @@ | ||
const assetRel = relative(dirname(wrapperFile), assetFile); | ||
return markRelative(posix.normalize(assetRel)); | ||
return markRelative(slash(normalize(assetRel))); | ||
} | ||
return markRelative(assetsPath ? posix.join(assetsPath, assetName) : assetName); | ||
return markRelative(slash(assetsPath ? join(assetsPath, assetName) : assetName)); | ||
} | ||
@@ -379,3 +383,3 @@ | ||
} else if (mode === "rebase") { | ||
const assetName = posix.relative(options.rebasePath, id); | ||
const assetName = relative(options.rebasePath, id); | ||
value = options.keepImport ? getAssetImportPath(assetName) : getAssetPublicPath(assetName, options.publicPath); | ||
@@ -382,0 +386,0 @@ } else { |
{ | ||
"name": "rollup-plugin-smart-asset", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Rollup plugin to rebase, inline or copy assets referenced from the code", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import { promisify } from "util" | ||
import { stat, readFile, copyFileSync } from "fs" | ||
import { join, extname, dirname, parse, relative, posix } from "path" | ||
import { join, extname, dirname, parse, relative, normalize } from "path" | ||
@@ -14,2 +14,7 @@ import { sync as mkdirpSync } from "mkdirp" | ||
// replace windows paths to unix paths on windows platform | ||
function slash(path) { | ||
return path.replace(/\\/g, "/") | ||
} | ||
function markRelative(path) { | ||
@@ -28,3 +33,3 @@ if (path.substr(0, 3) === "../" || path.substr(0, 2) === "./" || path.substr(0, 1) === "/") { | ||
function getAssetPublicPath(assetName, publicPath) { | ||
return publicPath ? posix.join(publicPath, assetName) : assetName | ||
return slash(publicPath ? join(publicPath, assetName) : assetName) | ||
} | ||
@@ -37,5 +42,5 @@ | ||
const assetRel = relative(dirname(wrapperFile), assetFile) | ||
return markRelative(posix.normalize(assetRel)) | ||
return markRelative(slash(normalize(assetRel))) | ||
} | ||
return markRelative(assetsPath ? posix.join(assetsPath, assetName) : assetName) | ||
return markRelative(slash(assetsPath ? join(assetsPath, assetName) : assetName)) | ||
} | ||
@@ -180,3 +185,3 @@ | ||
} else if (mode === "rebase") { | ||
const assetName = posix.relative(options.rebasePath, id) | ||
const assetName = relative(options.rebasePath, id) | ||
value = options.keepImport | ||
@@ -183,0 +188,0 @@ ? getAssetImportPath(assetName) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69309
25
1617