1 | /*
|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
3 | Author Ivan Kopeykin @vankop
|
4 | */
|
5 |
|
6 | ;
|
7 |
|
8 | const makeSerializable = require("../util/makeSerializable");
|
9 | const ModuleDependency = require("./ModuleDependency");
|
10 |
|
11 | /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
12 | /** @typedef {import("../ChunkGraph")} ChunkGraph */
|
13 | /** @typedef {import("../Dependency")} Dependency */
|
14 | /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
15 | /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
16 | /** @typedef {import("../Module")} Module */
|
17 | /** @typedef {import("../ModuleGraph")} ModuleGraph */
|
18 | /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
19 | /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
20 | /** @typedef {import("../util/Hash")} Hash */
|
21 | /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
22 |
|
23 | class CssImportDependency extends ModuleDependency {
|
24 | /**
|
25 | * @param {string} request request
|
26 | * @param {[number, number]} range range of the argument
|
27 | * @param {string | undefined} supports list of supports conditions
|
28 | * @param {string | undefined} media list of media conditions
|
29 | */
|
30 | constructor(request, range, supports, media) {
|
31 | super(request);
|
32 | this.range = range;
|
33 | this.supports = supports;
|
34 | this.media = media;
|
35 | }
|
36 |
|
37 | get type() {
|
38 | return "css @import";
|
39 | }
|
40 |
|
41 | get category() {
|
42 | return "css-import";
|
43 | }
|
44 |
|
45 | /**
|
46 | * @param {string} context context directory
|
47 | * @returns {Module} a module
|
48 | */
|
49 | createIgnoredModule(context) {
|
50 | return null;
|
51 | }
|
52 | }
|
53 |
|
54 | CssImportDependency.Template = class CssImportDependencyTemplate extends (
|
55 | ModuleDependency.Template
|
56 | ) {
|
57 | /**
|
58 | * @param {Dependency} dependency the dependency for which the template should be applied
|
59 | * @param {ReplaceSource} source the current replace source which can be modified
|
60 | * @param {DependencyTemplateContext} templateContext the context object
|
61 | * @returns {void}
|
62 | */
|
63 | apply(dependency, source, templateContext) {
|
64 | const dep = /** @type {CssImportDependency} */ (dependency);
|
65 |
|
66 | source.replace(dep.range[0], dep.range[1] - 1, "");
|
67 | }
|
68 | };
|
69 |
|
70 | makeSerializable(
|
71 | CssImportDependency,
|
72 | "webpack/lib/dependencies/CssImportDependency"
|
73 | );
|
74 |
|
75 | module.exports = CssImportDependency;
|