* Generate the merged CSS text for a module, optionally wrapped as a * JS string literal for embedding in JavaScript output. * @param {NormalModule} module the module * @param {GenerateContext} generateContext the generate context * @param {boolean} asJsLiteral wrap the result as a JS string
(module, generateContext, asJsLiteral)
| 933 | * @returns {Source} the CSS text source |
| 934 | */ |
| 935 | _generateCssText(module, generateContext, asJsLiteral) { |
| 936 | const cssSource = this._renderMergedCss(module, generateContext, new Set()); |
| 937 | const effectiveCharset = this._getEffectiveCharset( |
| 938 | module, |
| 939 | generateContext.moduleGraph |
| 940 | ); |
| 941 | |
| 942 | let result; |
| 943 | if (effectiveCharset !== undefined) { |
| 944 | const prefix = `@charset "${effectiveCharset}";\n`; |
| 945 | result = cssSource |
| 946 | ? new ConcatSource(prefix, cssSource) |
| 947 | : new RawSource(prefix); |
| 948 | } else { |
| 949 | result = cssSource; |
| 950 | } |
| 951 | |
| 952 | if (asJsLiteral) { |
| 953 | const devtool = |
| 954 | generateContext.runtimeTemplate.compilation.options.devtool; |
| 955 | return result |
| 956 | ? this._cssToJsLiteral(result, devtool, generateContext) |
| 957 | : new RawSource('""'); |
| 958 | } |
| 959 | return result || new RawSource(""); |
| 960 | } |
| 961 | } |
| 962 | |
| 963 | module.exports = CssGenerator; |
no test coverage detected