| | |
| | | /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ |
| | | /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */ |
| | | /** @typedef {import("../Dependency")} Dependency */ |
| | | /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ |
| | | /** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */ |
| | | /** @typedef {import("../Module")} Module */ |
| | | /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ |
| | | /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */ |
| | | /** @typedef {import("../javascript/JavascriptParser").Range} Range */ |
| | | /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ |
| | | /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ |
| | |
| | | |
| | | class CssUrlDependency extends ModuleDependency { |
| | | /** |
| | | * Creates an instance of CssUrlDependency. |
| | | * @param {string} request request |
| | | * @param {Range} range range of the argument |
| | | * @param {"string" | "url" | "src"} urlType dependency type e.g. url() or string |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates an ignored module. |
| | | * @param {string} context context directory |
| | | * @returns {Module} ignored module |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @param {ObjectSerializerContext} context context |
| | | */ |
| | | serialize(context) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | */ |
| | | deserialize(context) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns string in quotes if needed. |
| | | * @param {string} str string |
| | | * @returns {string} string in quotes if needed |
| | | */ |
| | |
| | | ModuleDependency.Template |
| | | ) { |
| | | /** |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Dependency} dependency the dependency for which the template should be applied |
| | | * @param {ReplaceSource} source the current replace source which can be modified |
| | | * @param {DependencyTemplateContext} templateContext the context object |
| | |
| | | apply( |
| | | dependency, |
| | | source, |
| | | { moduleGraph, runtimeTemplate, codeGenerationResults } |
| | | { type, moduleGraph, runtimeTemplate, codeGenerationResults } |
| | | ) { |
| | | if (type === "javascript") return; |
| | | const dep = /** @type {CssUrlDependency} */ (dependency); |
| | | const module = /** @type {Module} */ (moduleGraph.getModule(dep)); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the url of the asset. |
| | | * @param {object} options options object |
| | | * @param {Module} options.module the module |
| | | * @param {RuntimeSpec=} options.runtime runtime |
| | |
| | | return "data:,"; |
| | | } |
| | | const codeGen = codeGenerationResults.get(module, runtime); |
| | | const data = |
| | | /** @type {NonNullable<CodeGenerationResult["data"]>} */ |
| | | (codeGen.data); |
| | | const data = codeGen.data; |
| | | if (!data) return "data:,"; |
| | | const url = data.get("url"); |
| | | if (!url || !url["css-url"]) return "data:,"; |