html-loader
Advanced tools
Comparing version 2.1.2 to 3.0.0
"use strict"; | ||
const loader = require('./index'); | ||
const loader = require("./index"); | ||
module.exports = loader.default; | ||
module.exports.raw = loader.raw; |
@@ -10,7 +10,7 @@ "use strict"; | ||
const result = []; | ||
let index = value.indexOf('\n'); | ||
let index = value.indexOf("\n"); | ||
while (index !== -1) { | ||
result.push(index + 1); | ||
index = value.indexOf('\n', index + 1); | ||
index = value.indexOf("\n", index + 1); | ||
} | ||
@@ -50,3 +50,3 @@ | ||
super(error); | ||
this.name = 'HtmlSourceError'; | ||
this.name = "HtmlSourceError"; | ||
this.message = `${this.name}: ${this.message}`; | ||
@@ -53,0 +53,0 @@ this.startOffset = startOffset; |
@@ -44,3 +44,5 @@ { | ||
"preprocessor": { | ||
"instanceof": "Function" | ||
"instanceof": "Function", | ||
"description": "Allows pre-processing of content before handling.", | ||
"link": "https://github.com/webpack-contrib/html-loader#preprocessor" | ||
}, | ||
@@ -62,9 +64,15 @@ "sources": { | ||
} | ||
] | ||
], | ||
"description": "By default every loadable attributes (for example - <img src='image.png'>) is imported (const img = require('./image.png'). You may need to specify loaders for images in your configuration.", | ||
"link": "https://github.com/webpack-contrib/html-loader#sources" | ||
}, | ||
"minimize": { | ||
"anyOf": [{ "type": "boolean" }, { "type": "object" }] | ||
"anyOf": [{ "type": "boolean" }, { "type": "object" }], | ||
"description": "Tell html-loader to minimize HTML.", | ||
"link": "https://github.com/webpack-contrib/html-loader#minimize" | ||
}, | ||
"esModule": { | ||
"type": "boolean" | ||
"type": "boolean", | ||
"description": "Enable or disable ES modules syntax.", | ||
"link": "https://github.com/webpack-contrib/html-loader#esmodule" | ||
} | ||
@@ -71,0 +79,0 @@ }, |
@@ -6,12 +6,12 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "sourcesPlugin", { | ||
Object.defineProperty(exports, "minimizerPlugin", { | ||
enumerable: true, | ||
get: function () { | ||
return _sourcesPlugin.default; | ||
return _minimizerPlugin.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "minimizerPlugin", { | ||
Object.defineProperty(exports, "sourcesPlugin", { | ||
enumerable: true, | ||
get: function () { | ||
return _minimizerPlugin.default; | ||
return _sourcesPlugin.default; | ||
} | ||
@@ -18,0 +18,0 @@ }); |
@@ -10,6 +10,6 @@ "use strict"; | ||
var _default = options => function process(html) { | ||
var _default = options => async function process(html) { | ||
try { | ||
// eslint-disable-next-line no-param-reassign | ||
html = (0, _htmlMinifierTerser.minify)(html, options.minimize); | ||
html = await (0, _htmlMinifierTerser.minify)(html, options.minimize); | ||
} catch (error) { | ||
@@ -16,0 +16,0 @@ options.errors.push(error); |
@@ -29,7 +29,7 @@ "use strict"; | ||
if (node.nodeName === '#comment') { | ||
if (node.nodeName === "#comment") { | ||
const match = node.data.match(_utils.webpackIgnoreCommentRegexp); | ||
if (match) { | ||
needIgnore = match[2] === 'true'; | ||
needIgnore = match[2] === "true"; | ||
} | ||
@@ -54,3 +54,3 @@ | ||
name = attribute.prefix ? `${attribute.prefix}:${name}` : name; | ||
const handlers = options.sources.list.get(tagName.toLowerCase()) || options.sources.list.get('*'); | ||
const handlers = options.sources.list.get(tagName.toLowerCase()) || options.sources.list.get("*"); | ||
@@ -77,5 +77,11 @@ if (!handlers) { | ||
tag: tagName, | ||
isSelfClosing: node.selfClosing, | ||
tagStartOffset: sourceCodeLocation.startOffset, | ||
tagEndOffset: sourceCodeLocation.endOffset, | ||
startTag: { | ||
startOffset: sourceCodeLocation.startTag.startOffset, | ||
endOffset: sourceCodeLocation.startTag.endOffset | ||
}, | ||
endTag: sourceCodeLocation.endTag ? { | ||
startOffset: sourceCodeLocation.endTag.startOffset, | ||
endOffset: sourceCodeLocation.endTag.endOffset | ||
} : // eslint-disable-next-line no-undefined | ||
undefined, | ||
attributes, | ||
@@ -126,16 +132,9 @@ attribute: name, | ||
isValueQuoted, | ||
format, | ||
runtime, | ||
startOffset, | ||
endOffset | ||
} = source; | ||
let normalizedUrl = value; | ||
let prefix = ''; | ||
const queryParts = normalizedUrl.split('!'); | ||
let request = value; | ||
if (queryParts.length > 1) { | ||
normalizedUrl = queryParts.pop(); | ||
prefix = queryParts.join('!'); | ||
} | ||
normalizedUrl = (0, _utils.normalizeUrl)(normalizedUrl); | ||
if (!urlFilter(name, value, options.resourcePath)) { | ||
@@ -147,20 +146,19 @@ // eslint-disable-next-line no-continue | ||
let hash; | ||
const indexHash = normalizedUrl.lastIndexOf('#'); | ||
const indexHash = request.lastIndexOf("#"); | ||
if (indexHash >= 0) { | ||
hash = normalizedUrl.substring(indexHash); | ||
normalizedUrl = normalizedUrl.substring(0, indexHash); | ||
hash = request.substring(indexHash); | ||
request = request.substring(0, indexHash); | ||
} | ||
const request = (0, _utils.requestify)(normalizedUrl); | ||
const newUrl = prefix ? `${prefix}!${request}` : request; | ||
const importKey = newUrl; | ||
let importName = imports.get(importKey); | ||
request = (0, _utils.requestify)(options.context, request); | ||
let importName = imports.get(request); | ||
if (!importName) { | ||
importName = `___HTML_LOADER_IMPORT_${imports.size}___`; | ||
imports.set(importKey, importName); | ||
imports.set(request, importName); | ||
options.imports.push({ | ||
format, | ||
importName, | ||
source: newUrl | ||
request | ||
}); | ||
@@ -170,3 +168,3 @@ } | ||
const replacementKey = JSON.stringify({ | ||
newUrl, | ||
request, | ||
isValueQuoted, | ||
@@ -184,3 +182,4 @@ hash | ||
hash, | ||
isValueQuoted | ||
isValueQuoted, | ||
runtime | ||
}); | ||
@@ -187,0 +186,0 @@ } // eslint-disable-next-line no-param-reassign |
@@ -6,16 +6,15 @@ "use strict"; | ||
}); | ||
exports.c0ControlCodesExclude = c0ControlCodesExclude; | ||
exports.getExportCode = getExportCode; | ||
exports.getFilter = getFilter; | ||
exports.getImportCode = getImportCode; | ||
exports.getModuleCode = getModuleCode; | ||
exports.isUrlRequestable = isUrlRequestable; | ||
exports.normalizeOptions = normalizeOptions; | ||
exports.parseSrc = parseSrc; | ||
exports.parseSrcset = parseSrcset; | ||
exports.parseSrc = parseSrc; | ||
exports.normalizeUrl = normalizeUrl; | ||
exports.pluginRunner = pluginRunner; | ||
exports.requestify = requestify; | ||
exports.isUrlRequestable = isUrlRequestable; | ||
exports.srcType = srcType; | ||
exports.srcsetType = srcsetType; | ||
exports.normalizeOptions = normalizeOptions; | ||
exports.pluginRunner = pluginRunner; | ||
exports.getFilter = getFilter; | ||
exports.getImportCode = getImportCode; | ||
exports.getModuleCode = getModuleCode; | ||
exports.getExportCode = getExportCode; | ||
exports.c0ControlCodesExclude = c0ControlCodesExclude; | ||
exports.traverse = traverse; | ||
@@ -32,7 +31,7 @@ exports.webpackIgnoreCommentRegexp = void 0; | ||
return (// Horizontal tab | ||
character === '\u0009' || // New line | ||
character === '\u000A' || // Form feed | ||
character === '\u000C' || // Carriage return | ||
character === '\u000D' || // Space | ||
character === '\u0020' | ||
character === "\u0009" || // New line | ||
character === "\u000A" || // Form feed | ||
character === "\u000C" || // Carriage return | ||
character === "\u000D" || // Space | ||
character === "\u0020" | ||
); | ||
@@ -92,3 +91,3 @@ } // (Don't use \s, to avoid matching non-breaking space) | ||
if (candidates.length === 0) { | ||
throw new Error('Must contain one or more image candidate strings'); | ||
throw new Error("Must contain one or more image candidate strings"); | ||
} // (we're done, this is the sole return path) | ||
@@ -109,4 +108,4 @@ | ||
if (url.slice(-1) === ',') { | ||
url = url.replace(regexTrailingCommas, ''); // (Jump ahead to step 9 to skip tokenization and just push the candidate). | ||
if (url.slice(-1) === ",") { | ||
url = url.replace(regexTrailingCommas, ""); // (Jump ahead to step 9 to skip tokenization and just push the candidate). | ||
@@ -116,4 +115,4 @@ parseDescriptors(); | ||
else { | ||
tokenize(); | ||
} // 16. Return to the step labeled splitting loop. | ||
tokenize(); | ||
} // 16. Return to the step labeled splitting loop. | ||
@@ -131,5 +130,5 @@ } | ||
currentDescriptor = ''; // 8.3. Let state be in descriptor. | ||
currentDescriptor = ""; // 8.3. Let state be in descriptor. | ||
state = 'in descriptor'; // eslint-disable-next-line no-constant-condition | ||
state = "in descriptor"; // eslint-disable-next-line no-constant-condition | ||
@@ -143,3 +142,3 @@ while (true) { | ||
if (state === 'in descriptor') { | ||
if (state === "in descriptor") { | ||
// Do the following, depending on the value of c: | ||
@@ -153,4 +152,4 @@ // Space character | ||
descriptors.push(currentDescriptor); | ||
currentDescriptor = ''; | ||
state = 'after descriptor'; | ||
currentDescriptor = ""; | ||
state = "after descriptor"; | ||
} | ||
@@ -161,64 +160,64 @@ } // U+002C COMMA (,) | ||
// labeled descriptor parser. | ||
else if (c === ',') { | ||
position += 1; | ||
else if (c === ",") { | ||
position += 1; | ||
if (currentDescriptor) { | ||
descriptors.push(currentDescriptor); | ||
} | ||
if (currentDescriptor) { | ||
descriptors.push(currentDescriptor); | ||
} | ||
parseDescriptors(); | ||
return; | ||
} // U+0028 LEFT PARENTHESIS (() | ||
// Append c to current descriptor. Set state to in parens. | ||
else if (c === '\u0028') { | ||
currentDescriptor += c; | ||
state = 'in parens'; | ||
} // EOF | ||
// If current descriptor is not empty, append current descriptor to | ||
// descriptors. Jump to the step labeled descriptor parser. | ||
else if (c === '') { | ||
if (currentDescriptor) { | ||
descriptors.push(currentDescriptor); | ||
} | ||
parseDescriptors(); | ||
return; | ||
} // U+0028 LEFT PARENTHESIS (() | ||
// Append c to current descriptor. Set state to in parens. | ||
else if (c === "\u0028") { | ||
currentDescriptor += c; | ||
state = "in parens"; | ||
} // EOF | ||
// If current descriptor is not empty, append current descriptor to | ||
// descriptors. Jump to the step labeled descriptor parser. | ||
else if (c === "") { | ||
if (currentDescriptor) { | ||
descriptors.push(currentDescriptor); | ||
} | ||
parseDescriptors(); | ||
return; // Anything else | ||
// Append c to current descriptor. | ||
} else { | ||
currentDescriptor += c; | ||
} | ||
parseDescriptors(); | ||
return; // Anything else | ||
// Append c to current descriptor. | ||
} else { | ||
currentDescriptor += c; | ||
} | ||
} // In parens | ||
else if (state === 'in parens') { | ||
// U+0029 RIGHT PARENTHESIS ()) | ||
// Append c to current descriptor. Set state to in descriptor. | ||
if (c === ')') { | ||
currentDescriptor += c; | ||
state = 'in descriptor'; | ||
} // EOF | ||
// Append current descriptor to descriptors. Jump to the step labeled | ||
// descriptor parser. | ||
else if (c === '') { | ||
descriptors.push(currentDescriptor); | ||
parseDescriptors(); | ||
return; | ||
} // Anything else | ||
// Append c to current descriptor. | ||
else { | ||
currentDescriptor += c; | ||
} | ||
} // After descriptor | ||
else if (state === 'after descriptor') { | ||
// Do the following, depending on the value of c: | ||
if (isASCIIWhitespace(c)) {// Space character: Stay in this state. | ||
} // EOF: Jump to the step labeled descriptor parser. | ||
else if (c === '') { | ||
parseDescriptors(); | ||
return; | ||
} // Anything else | ||
// Set state to in descriptor. Set position to the previous character in input. | ||
else { | ||
state = 'in descriptor'; | ||
position -= 1; | ||
} | ||
} // Advance position to the next character in input. | ||
else if (state === "in parens") { | ||
// U+0029 RIGHT PARENTHESIS ()) | ||
// Append c to current descriptor. Set state to in descriptor. | ||
if (c === ")") { | ||
currentDescriptor += c; | ||
state = "in descriptor"; | ||
} // EOF | ||
// Append current descriptor to descriptors. Jump to the step labeled | ||
// descriptor parser. | ||
else if (c === "") { | ||
descriptors.push(currentDescriptor); | ||
parseDescriptors(); | ||
return; | ||
} // Anything else | ||
// Append c to current descriptor. | ||
else { | ||
currentDescriptor += c; | ||
} | ||
} // After descriptor | ||
else if (state === "after descriptor") { | ||
// Do the following, depending on the value of c: | ||
if (isASCIIWhitespace(c)) {// Space character: Stay in this state. | ||
} // EOF: Jump to the step labeled descriptor parser. | ||
else if (c === "") { | ||
parseDescriptors(); | ||
return; | ||
} // Anything else | ||
// Set state to in descriptor. Set position to the previous character in input. | ||
else { | ||
state = "in descriptor"; | ||
position -= 1; | ||
} | ||
} // Advance position to the next character in input. | ||
@@ -262,3 +261,3 @@ | ||
if (regexNonNegativeInteger.test(value) && lastChar === 'w') { | ||
if (regexNonNegativeInteger.test(value) && lastChar === "w") { | ||
// If width and density are not both absent, then let error be yes. | ||
@@ -279,37 +278,37 @@ if (w || d) { | ||
// a U+0078 LATIN SMALL LETTER X character | ||
else if (regexFloatingPoint.test(value) && lastChar === 'x') { | ||
// If width, density and future-compat-h are not all absent, then let error | ||
// be yes. | ||
if (w || d || h) { | ||
pError = true; | ||
} // Apply the rules for parsing floating-point number values to the descriptor. | ||
// If the result is less than zero, let error be yes. Otherwise, let density | ||
// be the result. | ||
else if (regexFloatingPoint.test(value) && lastChar === "x") { | ||
// If width, density and future-compat-h are not all absent, then let error | ||
// be yes. | ||
if (w || d || h) { | ||
pError = true; | ||
} // Apply the rules for parsing floating-point number values to the descriptor. | ||
// If the result is less than zero, let error be yes. Otherwise, let density | ||
// be the result. | ||
if (floatVal < 0) { | ||
pError = true; | ||
} else { | ||
d = floatVal; | ||
} | ||
} // If the descriptor consists of a valid non-negative integer followed by | ||
// a U+0068 LATIN SMALL LETTER H character | ||
else if (regexNonNegativeInteger.test(value) && lastChar === 'h') { | ||
// If height and density are not both absent, then let error be yes. | ||
if (h || d) { | ||
pError = true; | ||
} // Apply the rules for parsing non-negative integers to the descriptor. | ||
// If the result is zero, let error be yes. Otherwise, let future-compat-h | ||
// be the result. | ||
if (floatVal < 0) { | ||
pError = true; | ||
} else { | ||
d = floatVal; | ||
} | ||
} // If the descriptor consists of a valid non-negative integer followed by | ||
// a U+0068 LATIN SMALL LETTER H character | ||
else if (regexNonNegativeInteger.test(value) && lastChar === "h") { | ||
// If height and density are not both absent, then let error be yes. | ||
if (h || d) { | ||
pError = true; | ||
} // Apply the rules for parsing non-negative integers to the descriptor. | ||
// If the result is zero, let error be yes. Otherwise, let future-compat-h | ||
// be the result. | ||
if (intVal === 0) { | ||
pError = true; | ||
} else { | ||
h = intVal; | ||
} // Anything else, Let error be yes. | ||
if (intVal === 0) { | ||
pError = true; | ||
} else { | ||
h = intVal; | ||
} // Anything else, Let error be yes. | ||
} else { | ||
pError = true; | ||
} | ||
} else { | ||
pError = true; | ||
} | ||
} // 15. If error is still no, then append a new image source to candidates whose | ||
@@ -353,3 +352,3 @@ // URL is url, associated with a width width if not absent and a pixel | ||
if (!input) { | ||
throw new Error('Must be non-empty'); | ||
throw new Error("Must be non-empty"); | ||
} | ||
@@ -370,3 +369,3 @@ | ||
if (!value) { | ||
throw new Error('Must be non-empty'); | ||
throw new Error("Must be non-empty"); | ||
} | ||
@@ -380,31 +379,4 @@ | ||
const moduleRequestRegex = /^[^?]*~/; | ||
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i; | ||
const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]|^\\\\/; | ||
function normalizeUrl(url) { | ||
return matchNativeWin32Path.test(url) ? decodeURI(url).replace(/[\t\n\r]/g, '') : decodeURI(url).replace(/[\t\n\r]/g, '').replace(/\\/g, '/'); | ||
} | ||
function requestify(url) { | ||
if (matchNativeWin32Path.test(url) || url[0] === '/') { | ||
return url; | ||
} | ||
if (/^file:/i.test(url)) { | ||
return url; | ||
} | ||
if (/^\.\.?\//.test(url)) { | ||
return url; | ||
} // A `~` makes the url an module | ||
if (moduleRequestRegex.test(url)) { | ||
return url.replace(moduleRequestRegex, ''); | ||
} // every other url is threaded like a relative url | ||
return `./${url}`; | ||
} | ||
function isUrlRequestable(url) { | ||
@@ -422,3 +394,3 @@ // Protocol-relative URLs | ||
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !matchNativeWin32Path.test(url)) { | ||
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !WINDOWS_ABS_PATH_REGEXP.test(url)) { | ||
return false; | ||
@@ -435,4 +407,75 @@ } // It's some kind of url for a template | ||
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g; | ||
const RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/; | ||
const absoluteToRequest = (context, maybeAbsolutePath) => { | ||
if (maybeAbsolutePath[0] === "/") { | ||
if (maybeAbsolutePath.length > 1 && maybeAbsolutePath[maybeAbsolutePath.length - 1] === "/") { | ||
// this 'path' is actually a regexp generated by dynamic requires. | ||
// Don't treat it as an absolute path. | ||
return maybeAbsolutePath; | ||
} | ||
const querySplitPos = maybeAbsolutePath.indexOf("?"); | ||
let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); | ||
resource = _path.default.posix.relative(context, resource); | ||
if (!resource.startsWith("../")) { | ||
resource = `./${resource}`; | ||
} | ||
return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); | ||
} | ||
if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) { | ||
const querySplitPos = maybeAbsolutePath.indexOf("?"); | ||
let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); | ||
resource = _path.default.win32.relative(context, resource); | ||
if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) { | ||
resource = resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"); | ||
if (!resource.startsWith("../")) { | ||
resource = `./${resource}`; | ||
} | ||
} | ||
return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); | ||
} | ||
if (!RELATIVE_PATH_REGEXP.test(maybeAbsolutePath)) { | ||
return `./${maybeAbsolutePath.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/")}`; | ||
} // not an absolute path | ||
return maybeAbsolutePath; | ||
}; | ||
const contextify = (context, request) => request.split("!").map(r => absoluteToRequest(context, r)).join("!"); | ||
const MODULE_REQUEST_REGEXP = /^[^?]*~/; | ||
function requestify(context, request) { | ||
const isWindowsAbsolutePath = WINDOWS_ABS_PATH_REGEXP.test(request); | ||
const newRequest = isWindowsAbsolutePath ? decodeURI(request).replace(/[\t\n\r]/g, "") : decodeURI(request).replace(/[\t\n\r]/g, "").replace(/\\/g, "/"); | ||
if (isWindowsAbsolutePath || newRequest[0] === "/") { | ||
return newRequest; | ||
} | ||
if (/^file:/i.test(newRequest)) { | ||
return newRequest; | ||
} // A `~` makes the url an module | ||
if (MODULE_REQUEST_REGEXP.test(newRequest)) { | ||
return newRequest.replace(MODULE_REQUEST_REGEXP, ""); | ||
} // every other url is threaded like a relative url | ||
return contextify(context, newRequest); | ||
} | ||
function isProductionMode(loaderContext) { | ||
return loaderContext.mode === 'production' || !loaderContext.mode; | ||
return loaderContext.mode === "production" || !loaderContext.mode; | ||
} | ||
@@ -460,7 +503,7 @@ | ||
function getMinimizeOption(rawOptions, loaderContext) { | ||
if (typeof rawOptions.minimize === 'undefined') { | ||
if (typeof rawOptions.minimize === "undefined") { | ||
return isProductionMode(loaderContext) ? defaultMinimizerOptions : false; | ||
} | ||
if (typeof rawOptions.minimize === 'boolean') { | ||
if (typeof rawOptions.minimize === "boolean") { | ||
return rawOptions.minimize === true ? defaultMinimizerOptions : false; | ||
@@ -474,7 +517,7 @@ } | ||
const [result] = attributes.filter(i => i.name.toLowerCase() === name); | ||
return typeof result === 'undefined' ? result : result.value; | ||
return typeof result === "undefined" ? result : result.value; | ||
} | ||
function scriptSrcFilter(tag, attribute, attributes) { | ||
let type = getAttributeValue(attributes, 'type'); | ||
let type = getAttributeValue(attributes, "type"); | ||
@@ -491,3 +534,3 @@ if (!type) { | ||
if (type !== 'module' && type !== 'text/javascript' && type !== 'application/javascript') { | ||
if (type !== "module" && type !== "text/javascript" && type !== "application/javascript") { | ||
return false; | ||
@@ -500,3 +543,3 @@ } | ||
function linkHrefFilter(tag, attribute, attributes) { | ||
let rel = getAttributeValue(attributes, 'rel'); | ||
let rel = getAttributeValue(attributes, "rel"); | ||
@@ -514,12 +557,12 @@ if (!rel) { | ||
rel = rel.toLowerCase(); | ||
const usedRels = rel.split(' ').filter(value => value); | ||
const allowedRels = ['stylesheet', 'icon', 'mask-icon', 'apple-touch-icon', 'apple-touch-icon-precomposed', 'apple-touch-startup-image', 'manifest', 'prefetch', 'preload']; | ||
const usedRels = rel.split(" ").filter(value => value); | ||
const allowedRels = ["stylesheet", "icon", "mask-icon", "apple-touch-icon", "apple-touch-icon-precomposed", "apple-touch-startup-image", "manifest", "prefetch", "preload"]; | ||
return allowedRels.filter(value => usedRels.includes(value)).length > 0; | ||
} | ||
const META = new Map([['name', new Set([// msapplication-TileImage | ||
'msapplication-tileimage', 'msapplication-square70x70logo', 'msapplication-square150x150logo', 'msapplication-wide310x150logo', 'msapplication-square310x310logo', 'msapplication-config', 'msapplication-task', 'twitter:image'])], ['property', new Set(['og:image', 'og:image:url', 'og:image:secure_url', 'og:audio', 'og:audio:secure_url', 'og:video', 'og:video:secure_url', 'vk:image'])], ['itemprop', new Set(['image', 'logo', 'screenshot', 'thumbnailurl', 'contenturl', 'downloadurl', 'duringmedia', 'embedurl', 'installurl', 'layoutimage'])]]); | ||
const META = new Map([["name", new Set([// msapplication-TileImage | ||
"msapplication-tileimage", "msapplication-square70x70logo", "msapplication-square150x150logo", "msapplication-wide310x150logo", "msapplication-square310x310logo", "msapplication-config", "msapplication-task", "twitter:image"])], ["property", new Set(["og:image", "og:image:url", "og:image:secure_url", "og:audio", "og:audio:secure_url", "og:video", "og:video:secure_url", "vk:image"])], ["itemprop", new Set(["image", "logo", "screenshot", "thumbnailurl", "contenturl", "downloadurl", "duringmedia", "embedurl", "installurl", "layoutimage"])]]); | ||
function linkItempropFilter(tag, attribute, attributes) { | ||
let name = getAttributeValue(attributes, 'itemprop'); | ||
let name = getAttributeValue(attributes, "itemprop"); | ||
@@ -534,3 +577,3 @@ if (name) { | ||
name = name.toLowerCase(); | ||
return META.get('itemprop').has(name); | ||
return META.get("itemprop").has(name); | ||
} | ||
@@ -623,3 +666,3 @@ | ||
function metaContentType(options) { | ||
const isMsapplicationTask = options.attributes.find(i => i.name.toLowerCase() === 'name' && i.value.toLowerCase() === 'msapplication-task'); | ||
const isMsapplicationTask = options.attributes.find(i => i.name.toLowerCase() === "name" && i.value.toLowerCase() === "msapplication-task"); | ||
@@ -630,3 +673,3 @@ if (isMsapplicationTask) { | ||
let value; | ||
const parts = options.value.split(';'); | ||
const parts = options.value.split(";"); | ||
@@ -637,3 +680,3 @@ for (const [index, part] of parts.entries()) { | ||
if (/^icon-uri/i.test(part.trim())) { | ||
const [name, src] = part.split('='); | ||
const [name, src] = part.split("="); | ||
startOffset += name.length + 1; | ||
@@ -673,58 +716,106 @@ let source; | ||
return srcType(options); | ||
} | ||
} // function webpackImportType(options) { | ||
// let source; | ||
// | ||
// try { | ||
// source = parseSrc(options.value); | ||
// } catch (error) { | ||
// throw new HtmlSourceError( | ||
// `Bad value for attribute "${options.attribute}" on element "${options.tag}": ${error.message}`, | ||
// options.attributeStartOffset, | ||
// options.attributeEndOffset, | ||
// options.html | ||
// ); | ||
// } | ||
// | ||
// source = c0ControlCodesExclude(source); | ||
// | ||
// if (!isUrlRequestable(source.value)) { | ||
// return []; | ||
// } | ||
// | ||
// const { startOffset } = options.startTag; | ||
// let { endOffset } = options.startTag; | ||
// | ||
// if (options.endTag) { | ||
// ({ endOffset } = options.endTag); | ||
// } | ||
// | ||
// return [ | ||
// { | ||
// format: 'import', | ||
// runtime: false, | ||
// value: source.value, | ||
// startOffset, | ||
// endOffset, | ||
// }, | ||
// ]; | ||
// } | ||
const defaultSources = new Map([['audio', new Map([['src', { | ||
const defaultSources = new Map([["audio", new Map([["src", { | ||
type: srcType | ||
}]])], ['embed', new Map([['src', { | ||
}]])], ["embed", new Map([["src", { | ||
type: srcType | ||
}]])], ['img', new Map([['src', { | ||
}]])], ["img", new Map([["src", { | ||
type: srcType | ||
}], ['srcset', { | ||
}], ["srcset", { | ||
type: srcsetType | ||
}]])], ['input', new Map([['src', { | ||
}]])], ["input", new Map([["src", { | ||
type: srcType | ||
}]])], ['link', new Map([['href', { | ||
}]])], ["link", new Map([["href", { | ||
type: srcType, | ||
filter: linkUnionFilter | ||
}], ['imagesrcset', { | ||
}], ["imagesrcset", { | ||
type: srcsetType, | ||
filter: linkHrefFilter | ||
}]])], ['meta', new Map([['content', { | ||
}]])], ["meta", new Map([["content", { | ||
type: metaContentType, | ||
filter: metaContentFilter | ||
}]])], ['object', new Map([['data', { | ||
}]])], ["object", new Map([["data", { | ||
type: srcType | ||
}]])], ['script', new Map([['src', { | ||
}]])], ["script", new Map([["src", { | ||
type: srcType, | ||
filter: scriptSrcFilter | ||
}], // Using href with <script> is described here: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/script | ||
['href', { | ||
["href", { | ||
type: srcType, | ||
filter: scriptSrcFilter | ||
}], ['xlink:href', { | ||
}], ["xlink:href", { | ||
type: srcType, | ||
filter: scriptSrcFilter | ||
}]])], ['source', new Map([['src', { | ||
}]])], ["source", new Map([["src", { | ||
type: srcType | ||
}], ['srcset', { | ||
}], ["srcset", { | ||
type: srcsetType | ||
}]])], ['track', new Map([['src', { | ||
}]])], ["track", new Map([["src", { | ||
type: srcType | ||
}]])], ['video', new Map([['poster', { | ||
}]])], ["video", new Map([["poster", { | ||
type: srcType | ||
}], ['src', { | ||
}], ["src", { | ||
type: srcType | ||
}]])], // SVG | ||
['image', new Map([['xlink:href', { | ||
["image", new Map([["xlink:href", { | ||
type: srcType | ||
}], ['href', { | ||
}], ["href", { | ||
type: srcType | ||
}]])], ['use', new Map([['xlink:href', { | ||
}]])], ["use", new Map([["xlink:href", { | ||
type: srcType | ||
}], ['href', { | ||
}], ["href", { | ||
type: srcType | ||
}]])]]); | ||
}]])] // [ | ||
// 'webpack-import', | ||
// new Map([ | ||
// [ | ||
// 'src', | ||
// { | ||
// type: webpackImportType, | ||
// }, | ||
// ], | ||
// ]), | ||
// ], | ||
]); | ||
function normalizeSourcesList(sources) { | ||
if (typeof sources === 'undefined') { | ||
if (typeof sources === "undefined") { | ||
return defaultSources; | ||
@@ -736,3 +827,3 @@ } | ||
for (const source of sources) { | ||
if (source === '...') { | ||
if (source === "...") { | ||
for (const [tag, attributes] of defaultSources.entries()) { | ||
@@ -756,4 +847,4 @@ let newAttributes; | ||
let { | ||
tag = '*', | ||
attribute = '*' | ||
tag = "*", | ||
attribute = "*" | ||
} = source; | ||
@@ -770,7 +861,7 @@ tag = tag.toLowerCase(); | ||
switch (source.type) { | ||
case 'src': | ||
case "src": | ||
typeFn = srcType; | ||
break; | ||
case 'srcset': | ||
case "srcset": | ||
typeFn = srcsetType; | ||
@@ -790,3 +881,3 @@ break; | ||
function getSourcesOption(rawOptions) { | ||
if (typeof rawOptions.sources === 'undefined') { | ||
if (typeof rawOptions.sources === "undefined") { | ||
return { | ||
@@ -797,3 +888,3 @@ list: normalizeSourcesList() | ||
if (typeof rawOptions.sources === 'boolean') { | ||
if (typeof rawOptions.sources === "boolean") { | ||
return rawOptions.sources === true ? { | ||
@@ -816,3 +907,3 @@ list: normalizeSourcesList() | ||
minimize: getMinimizeOption(rawOptions, loaderContext), | ||
esModule: typeof rawOptions.esModule === 'undefined' ? true : rawOptions.esModule | ||
esModule: typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule | ||
}; | ||
@@ -823,8 +914,8 @@ } | ||
return { | ||
process: content => { | ||
async process(content) { | ||
const result = {}; | ||
for (const plugin of plugins) { | ||
// eslint-disable-next-line no-param-reassign | ||
content = plugin(content, result); | ||
// eslint-disable-next-line no-param-reassign, no-await-in-loop | ||
content = await plugin(content, result); | ||
} | ||
@@ -835,2 +926,3 @@ | ||
} | ||
}; | ||
@@ -841,3 +933,3 @@ } | ||
return (attribute, value, resourcePath) => { | ||
if (typeof filter === 'function') { | ||
if (typeof filter === "function") { | ||
return filter(attribute, value, resourcePath); | ||
@@ -850,54 +942,13 @@ } | ||
const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]|^\\\\/; | ||
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g; | ||
const GET_SOURCE_FROM_IMPORT_NAME = "___HTML_LOADER_GET_SOURCE_FROM_IMPORT___"; | ||
const absoluteToRequest = (context, maybeAbsolutePath) => { | ||
if (maybeAbsolutePath[0] === '/') { | ||
if (maybeAbsolutePath.length > 1 && maybeAbsolutePath[maybeAbsolutePath.length - 1] === '/') { | ||
// this 'path' is actually a regexp generated by dynamic requires. | ||
// Don't treat it as an absolute path. | ||
return maybeAbsolutePath; | ||
} | ||
function getImportCode(html, loaderContext, imports, options) { | ||
if (imports.length === 0) { | ||
return ""; | ||
} // TODO simplif in the next major release | ||
const querySplitPos = maybeAbsolutePath.indexOf('?'); | ||
let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); | ||
resource = _path.default.posix.relative(context, resource); | ||
if (!resource.startsWith('../')) { | ||
resource = `./${resource}`; | ||
} | ||
const getURLRuntime = require.resolve("./runtime/getUrl.js"); | ||
return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); | ||
} | ||
if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) { | ||
const querySplitPos = maybeAbsolutePath.indexOf('?'); | ||
let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); | ||
resource = _path.default.win32.relative(context, resource); | ||
if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) { | ||
resource = resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, '/'); | ||
if (!resource.startsWith('../')) { | ||
resource = `./${resource}`; | ||
} | ||
} | ||
return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); | ||
} // not an absolute path | ||
return maybeAbsolutePath; | ||
}; | ||
const contextify = (context, request) => request.split('!').map(r => absoluteToRequest(context, r)).join('!'); | ||
const GET_SOURCE_FROM_IMPORT_NAME = '___HTML_LOADER_GET_SOURCE_FROM_IMPORT___'; | ||
function getImportCode(html, loaderContext, imports, options) { | ||
if (imports.length === 0) { | ||
return ''; | ||
} | ||
const fileURLToHelper = contextify(loaderContext.context, require.resolve('./runtime/getUrl.js')); | ||
const fileURLToHelper = typeof loaderContext.utils !== "undefined" && typeof loaderContext.utils.contextify === "function" ? loaderContext.utils.contextify(loaderContext.context, getURLRuntime) : contextify(loaderContext.context, getURLRuntime); | ||
let code = options.esModule ? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n` : `var ${GET_SOURCE_FROM_IMPORT_NAME} = require("${fileURLToHelper}");\n`; | ||
@@ -907,6 +958,16 @@ | ||
const { | ||
format, | ||
importName, | ||
source | ||
request | ||
} = item; | ||
code += options.esModule ? `var ${importName} = new URL("${source}", import.meta.url);\n` : `var ${importName} = require("${source}");\n`; | ||
switch (format) { | ||
case "import": | ||
code += options.esModule ? `import ${importName} from ${JSON.stringify(request)};\n` : `var ${importName} = require(${JSON.stringify(request)});\n`; | ||
break; | ||
case "url": | ||
default: | ||
code += options.esModule ? `var ${importName} = new URL(${JSON.stringify(request)}, import.meta.url);\n` : `var ${importName} = require(${JSON.stringify(request)});\n`; | ||
} | ||
} | ||
@@ -919,7 +980,8 @@ | ||
let code = JSON.stringify(html) // Invalid in JavaScript but valid HTML | ||
.replace(/[\u2028\u2029]/g, str => str === '\u2029' ? '\\u2029' : '\\u2028'); | ||
let replacersCode = ''; | ||
.replace(/[\u2028\u2029]/g, str => str === "\u2029" ? "\\u2029" : "\\u2028"); | ||
let replacersCode = ""; | ||
for (const item of replacements) { | ||
const { | ||
runtime, | ||
importName, | ||
@@ -930,6 +992,11 @@ replacementName, | ||
} = item; | ||
const getUrlOptions = [].concat(hash ? [`hash: ${JSON.stringify(hash)}`] : []).concat(isValueQuoted ? [] : 'maybeNeedQuotes: true'); | ||
const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(', ')} }` : ''; | ||
replacersCode += `var ${replacementName} = ${GET_SOURCE_FROM_IMPORT_NAME}(${importName}${preparedOptions});\n`; | ||
code = code.replace(new RegExp(replacementName, 'g'), () => `" + ${replacementName} + "`); | ||
if (typeof runtime === "undefined" || runtime === true) { | ||
const getUrlOptions = [].concat(hash ? [`hash: ${JSON.stringify(hash)}`] : []).concat(isValueQuoted ? [] : "maybeNeedQuotes: true"); | ||
const preparedOptions = getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(", ")} }` : ""; | ||
replacersCode += `var ${replacementName} = ${GET_SOURCE_FROM_IMPORT_NAME}(${importName}${preparedOptions});\n`; | ||
code = code.replace(new RegExp(replacementName, "g"), () => `" + ${replacementName} + "`); | ||
} else { | ||
code = code.replace(new RegExp(replacementName, "g"), () => `" + ${importName} + "`); | ||
} | ||
} | ||
@@ -961,3 +1028,3 @@ | ||
if (!value) { | ||
throw new Error('Must be non-empty'); | ||
throw new Error("Must be non-empty"); | ||
} | ||
@@ -975,3 +1042,3 @@ | ||
if (!value) { | ||
throw new Error('Must be non-empty'); | ||
throw new Error("Must be non-empty"); | ||
} | ||
@@ -978,0 +1045,0 @@ |
{ | ||
"name": "html-loader", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"description": "Html loader module for webpack", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">= 10.13.0" | ||
"node": ">= 12.13.0" | ||
}, | ||
@@ -27,3 +27,3 @@ "scripts": { | ||
"commitlint": "commitlint --from=master", | ||
"security": "npm audit", | ||
"security": "npm audit --production", | ||
"lint:prettier": "prettier --list-different .", | ||
@@ -37,8 +37,4 @@ "lint:js": "eslint --cache .", | ||
"test": "npm run test:coverage", | ||
"prepare": "npm run build", | ||
"release": "standard-version", | ||
"defaults": "webpack-defaults", | ||
"_postinstall": "husky install", | ||
"prepublishOnly": "pinst --disable", | ||
"postpublish": "pinst --enable" | ||
"prepare": "husky install && npm run build", | ||
"release": "standard-version" | ||
}, | ||
@@ -52,35 +48,33 @@ "files": [ | ||
"dependencies": { | ||
"html-minifier-terser": "^5.1.1", | ||
"html-minifier-terser": "^6.0.2", | ||
"parse5": "^6.0.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.12.10", | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"@webpack-contrib/defaults": "^6.3.0", | ||
"@babel/cli": "^7.14.5", | ||
"@babel/core": "^7.14.6", | ||
"@babel/preset-env": "^7.14.7", | ||
"@commitlint/cli": "^13.1.0", | ||
"@commitlint/config-conventional": "^13.1.0", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"babel-jest": "^26.6.3", | ||
"babel-jest": "^27.0.5", | ||
"cross-env": "^7.0.3", | ||
"del": "^6.0.0", | ||
"del-cli": "^3.0.1", | ||
"es-check": "^5.2.0", | ||
"eslint": "^7.20.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"handlebars": "^4.7.6", | ||
"html-webpack-plugin": "^5.2.0", | ||
"husky": "^5.0.9", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.4", | ||
"memfs": "^3.2.0", | ||
"del-cli": "^4.0.0", | ||
"es-check": "^6.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.23.4", | ||
"handlebars": "^4.7.7", | ||
"html-webpack-plugin": "^5.3.2", | ||
"husky": "^7.0.0", | ||
"jest": "^27.0.5", | ||
"lint-staged": "^11.0.0", | ||
"memfs": "^3.2.2", | ||
"npm-run-all": "^4.1.5", | ||
"pinst": "^2.1.4", | ||
"posthtml": "^0.15.1", | ||
"posthtml": "^0.16.4", | ||
"posthtml-webp": "^2.1.0", | ||
"prettier": "^2.1.2", | ||
"standard-version": "^9.0.0", | ||
"prettier": "^2.3.1", | ||
"standard-version": "^9.3.0", | ||
"unescape-unicode": "^0.2.0", | ||
"webpack": "^5.21.2" | ||
"webpack": "^5.40.0" | ||
}, | ||
@@ -87,0 +81,0 @@ "keywords": [ |
150
README.md
@@ -33,3 +33,3 @@ <div align="center"> | ||
```js | ||
import html from './file.html'; | ||
import html from "./file.html"; | ||
``` | ||
@@ -45,3 +45,3 @@ | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
}, | ||
@@ -107,3 +107,3 @@ ], | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -133,3 +133,3 @@ // Disables attributes processing | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -139,12 +139,12 @@ sources: { | ||
// All default supported tags and attributes | ||
'...', | ||
"...", | ||
{ | ||
tag: 'img', | ||
attribute: 'data-src', | ||
type: 'src', | ||
tag: "img", | ||
attribute: "data-src", | ||
type: "src", | ||
}, | ||
{ | ||
tag: 'img', | ||
attribute: 'data-srcset', | ||
type: 'srcset', | ||
tag: "img", | ||
attribute: "data-srcset", | ||
type: "srcset", | ||
}, | ||
@@ -190,3 +190,3 @@ ], | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -196,20 +196,20 @@ sources: { | ||
// All default supported tags and attributes | ||
'...', | ||
"...", | ||
{ | ||
tag: 'img', | ||
attribute: 'data-src', | ||
type: 'src', | ||
tag: "img", | ||
attribute: "data-src", | ||
type: "src", | ||
}, | ||
{ | ||
tag: 'img', | ||
attribute: 'data-srcset', | ||
type: 'srcset', | ||
tag: "img", | ||
attribute: "data-srcset", | ||
type: "srcset", | ||
}, | ||
{ | ||
// Tag name | ||
tag: 'link', | ||
tag: "link", | ||
// Attribute name | ||
attribute: 'href', | ||
attribute: "href", | ||
// Type of processing, can be `src` or `scrset` | ||
type: 'src', | ||
type: "src", | ||
// Allow to filter some attributes | ||
@@ -232,3 +232,3 @@ filter: (tag, attribute, attributes, resourcePath) => { | ||
attributes.type && | ||
attributes.type.trim().toLowerCase() !== 'text/css' | ||
attributes.type.trim().toLowerCase() !== "text/css" | ||
) { | ||
@@ -264,3 +264,3 @@ return false; | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -271,5 +271,5 @@ sources: { | ||
// Attribute name | ||
attribute: 'src', | ||
attribute: "src", | ||
// Type of processing, can be `src` or `scrset` | ||
type: 'src', | ||
type: "src", | ||
// Allow to filter some attributes (optional) | ||
@@ -283,3 +283,3 @@ filter: (tag, attribute, attributes, resourcePath) => { | ||
// choose all HTML tags except img tag | ||
return tag.toLowerCase() !== 'img'; | ||
return tag.toLowerCase() !== "img"; | ||
}, | ||
@@ -306,3 +306,3 @@ }, | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -312,9 +312,9 @@ sources: { | ||
{ | ||
tag: 'meta', | ||
attribute: 'content', | ||
type: 'src', | ||
tag: "meta", | ||
attribute: "content", | ||
type: "src", | ||
filter: (tag, attribute, attributes, resourcePath) => { | ||
if ( | ||
attributes.value === 'og:image' || | ||
attributes.name === 'twitter:image' | ||
attributes.value === "og:image" || | ||
attributes.name === "twitter:image" | ||
) { | ||
@@ -348,11 +348,11 @@ return true; | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
sources: { | ||
list: [ | ||
'...', | ||
"...", | ||
{ | ||
tag: 'img', | ||
attribute: 'src', | ||
type: 'src', | ||
tag: "img", | ||
attribute: "src", | ||
type: "src", | ||
filter: () => false, | ||
@@ -383,3 +383,3 @@ }, | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -431,3 +431,3 @@ sources: { | ||
```js | ||
const Handlebars = require('handlebars'); | ||
const Handlebars = require("handlebars"); | ||
@@ -439,3 +439,3 @@ module.exports = { | ||
test: /\.hbs$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -447,4 +447,4 @@ preprocessor: (content, loaderContext) => { | ||
result = Handlebars.compile(content)({ | ||
firstname: 'Value', | ||
lastname: 'OtherValue', | ||
firstname: "Value", | ||
lastname: "OtherValue", | ||
}); | ||
@@ -473,3 +473,3 @@ } catch (error) { | ||
```js | ||
const Handlebars = require('handlebars'); | ||
const Handlebars = require("handlebars"); | ||
@@ -481,3 +481,3 @@ module.exports = { | ||
test: /\.hbs$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -489,4 +489,4 @@ preprocessor: async (content, loaderContext) => { | ||
result = await Handlebars.compile(content)({ | ||
firstname: 'Value', | ||
lastname: 'OtherValue', | ||
firstname: "Value", | ||
lastname: "OtherValue", | ||
}); | ||
@@ -542,3 +542,3 @@ } catch (error) { | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -569,3 +569,3 @@ minimize: true, | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -601,3 +601,3 @@ minimize: { | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -653,3 +653,3 @@ esModule: false, | ||
test: /\.html$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: {}, | ||
@@ -659,3 +659,3 @@ }, | ||
test: /\.jpg$/, | ||
type: 'asset/resource', | ||
type: "asset/resource", | ||
}, | ||
@@ -665,3 +665,3 @@ ], | ||
resolve: { | ||
roots: [path.resolve(__dirname, 'fixtures')], | ||
roots: [path.resolve(__dirname, "fixtures")], | ||
}, | ||
@@ -691,7 +691,7 @@ }; | ||
test: /\.jpg$/, | ||
type: 'asset/resource', | ||
type: "asset/resource", | ||
}, | ||
{ | ||
test: /\.png$/, | ||
type: 'asset/inline', | ||
type: "asset/inline", | ||
}, | ||
@@ -701,3 +701,3 @@ ], | ||
output: { | ||
publicPath: 'http://cdn.example.com/[fullhash]/', | ||
publicPath: "http://cdn.example.com/[fullhash]/", | ||
}, | ||
@@ -716,3 +716,3 @@ }; | ||
```js | ||
require('html-loader!./file.html'); | ||
require("html-loader!./file.html"); | ||
@@ -775,5 +775,5 @@ // => '<img src="http://cdn.example.com/49eba9f/a992ca.jpg" data-src="image2x.png">' | ||
test: /\.html$/, | ||
type: 'asset/resource', | ||
type: "asset/resource", | ||
generator: { | ||
filename: '[name][ext]', | ||
filename: "[name][ext]", | ||
}, | ||
@@ -783,3 +783,3 @@ }, | ||
test: /\.html$/i, | ||
use: ['extract-loader', 'html-loader'], | ||
use: ["extract-loader", "html-loader"], | ||
}, | ||
@@ -789,7 +789,7 @@ { | ||
exclude: /\.file.js$/i, | ||
loader: 'babel-loader', | ||
loader: "babel-loader", | ||
}, | ||
{ | ||
test: /\.file.js$/i, | ||
type: 'asset/resource', | ||
type: "asset/resource", | ||
}, | ||
@@ -799,7 +799,7 @@ { | ||
exclude: /\.file.css$/i, | ||
loader: 'css-loader', | ||
loader: "css-loader", | ||
}, | ||
{ | ||
test: /\.file.css$/i, | ||
type: 'asset/resource', | ||
type: "asset/resource", | ||
}, | ||
@@ -827,3 +827,3 @@ ], | ||
```js | ||
const Handlebars = require('handlebars'); | ||
const Handlebars = require("handlebars"); | ||
@@ -835,3 +835,3 @@ module.exports = { | ||
test: /\.hbs$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -843,4 +843,4 @@ preprocessor: (content, loaderContext) => { | ||
result = Handlebars.compile(content)({ | ||
firstname: 'Value', | ||
lastname: 'OtherValue', | ||
firstname: "Value", | ||
lastname: "OtherValue", | ||
}); | ||
@@ -875,4 +875,4 @@ } catch (error) { | ||
```js | ||
const posthtml = require('posthtml'); | ||
const posthtmlWebp = require('posthtml-webp'); | ||
const posthtml = require("posthtml"); | ||
const posthtmlWebp = require("posthtml-webp"); | ||
@@ -884,3 +884,3 @@ module.exports = { | ||
test: /\.hbs$/i, | ||
loader: 'html-loader', | ||
loader: "html-loader", | ||
options: { | ||
@@ -928,3 +928,3 @@ preprocessor: (content, loaderContext) => { | ||
output: { | ||
assetModuleFilename: '[name][ext]', | ||
assetModuleFilename: "[name][ext]", | ||
}, | ||
@@ -935,5 +935,5 @@ module: { | ||
test: /\.html$/, | ||
type: 'asset/resource', | ||
type: "asset/resource", | ||
generator: { | ||
filename: '[name][ext]', | ||
filename: "[name][ext]", | ||
}, | ||
@@ -943,3 +943,3 @@ }, | ||
test: /\.html$/i, | ||
use: ['extract-loader', 'html-loader'], | ||
use: ["extract-loader", "html-loader"], | ||
}, | ||
@@ -946,0 +946,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
27
1226
68629
12
+ Addedclean-css@5.3.3(transitive)
+ Addedcommander@8.3.0(transitive)
+ Addedhtml-minifier-terser@6.1.0(transitive)
- Removedclean-css@4.2.4(transitive)
- Removedcommander@4.1.1(transitive)
- Removedhtml-minifier-terser@5.1.1(transitive)
- Removedterser@4.8.1(transitive)
Updatedhtml-minifier-terser@^6.0.2