@craftamap/esbuild-plugin-html
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -11,3 +11,2 @@ "use strict"; | ||
const lodash_template_1 = __importDefault(require("lodash.template")); | ||
const urlcat_1 = __importDefault(require("urlcat")); | ||
const defaultHtmlTemplate = ` | ||
@@ -95,2 +94,15 @@ <!DOCTYPE html> | ||
} | ||
// use the same joinWithPublicPath function as esbuild: | ||
// https://github.com/evanw/esbuild/blob/a1ff9d144cdb8d50ea2fa79a1d11f43d5bd5e2d8/internal/bundler/bundler.go#L533 | ||
function joinWithPublicPath(publicPath, relPath) { | ||
relPath = path_1.default.normalize(relPath); | ||
if (!publicPath) { | ||
publicPath = '.'; | ||
} | ||
let slash = '/'; | ||
if (publicPath.endsWith('/')) { | ||
slash = ''; | ||
} | ||
return `${publicPath}${slash}${relPath}`; | ||
} | ||
function injectFiles(dom, assets, outDir, publicPath, htmlFileConfiguration) { | ||
@@ -102,3 +114,3 @@ const document = dom.window.document; | ||
if (publicPath) { | ||
targetPath = (0, urlcat_1.default)(publicPath, path_1.default.relative(outDir, filepath)); | ||
targetPath = joinWithPublicPath(publicPath, path_1.default.relative(outDir, filepath)); | ||
} | ||
@@ -186,2 +198,5 @@ else { | ||
const out = path_1.default.join(outdir, htmlFileConfiguration.filename); | ||
await fs_1.promises.mkdir(path_1.default.dirname(out), { | ||
recursive: true, | ||
}); | ||
await fs_1.promises.writeFile(out, dom.serialize()); | ||
@@ -188,0 +203,0 @@ const stat = await fs_1.promises.stat(out); |
{ | ||
"name": "@craftamap/esbuild-plugin-html", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": "./lib/cjs/index.js", | ||
@@ -37,5 +37,4 @@ "repository": { | ||
"jsdom": "^17.0.0", | ||
"lodash.template": "^4.5.0", | ||
"urlcat": "^2.0.4" | ||
"lodash.template": "^4.5.0" | ||
} | ||
} |
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
19571
3
222
- Removedurlcat@^2.0.4
- Removedurlcat@2.0.4(transitive)