MCPcopy Index your code
hub / github.com/webpack/css-loader / loader

Function loader

src/index.js:33–274  ·  view source on GitHub ↗
(content, map, meta)

Source from the content-addressed store, hash-verified

31} from "./utils";
32
33export default async function loader(content, map, meta) {
34 const rawOptions = this.getOptions(schema);
35 const callback = this.async();
36
37 if (
38 this._compiler &&
39 this._compiler.options &&
40 this._compiler.options.experiments &&
41 this._compiler.options.experiments.css &&
42 this._module &&
43 (this._module.type === "css" ||
44 this._module.type === "css/auto" ||
45 this._module.type === "css/global" ||
46 this._module.type === "css/module")
47 ) {
48 this.emitWarning(
49 new Error(
50 'You can\'t use `experiments.css` (`experiments.futureDefaults` enable built-in CSS support by default) and `css-loader` together, please set `experiments.css` to `false` or set `{ type: "javascript/auto" }` for rules with `css-loader` in your webpack config (now css-loader does nothing).',
51 ),
52 );
53
54 callback(null, content, map, meta);
55
56 return;
57 }
58
59 let options;
60
61 try {
62 options = normalizeOptions(rawOptions, this);
63 } catch (error) {
64 callback(error);
65
66 return;
67 }
68
69 const plugins = [];
70 const replacements = [];
71 const exports = [];
72
73 if (shouldUseModulesPlugins(options)) {
74 plugins.push(...getModulesPlugins(options, this));
75 }
76
77 const importPluginImports = [];
78 const importPluginApi = [];
79
80 let isSupportAbsoluteURL = false;
81
82 // TODO enable by default in the next major release
83 if (
84 this._compilation &&
85 this._compilation.options &&
86 this._compilation.options.experiments &&
87 this._compilation.options.experiments.buildHttp
88 ) {
89 isSupportAbsoluteURL = true;
90 }

Callers

nothing calls this directly

Calls 15

normalizeOptionsFunction · 0.90
shouldUseModulesPluginsFunction · 0.90
getModulesPluginsFunction · 0.90
shouldUseImportPluginFunction · 0.90
stringifyRequestFunction · 0.90
combineRequestsFunction · 0.90
getPreRequesterFunction · 0.90
shouldUseURLPluginFunction · 0.90
getFilterFunction · 0.90
shouldUseIcssPluginFunction · 0.90
normalizeSourceMapFunction · 0.90
syntaxErrorFactoryFunction · 0.90

Tested by

no test coverage detected