|
1 | 1 | import fs from "fs"; |
2 | 2 | import path from "path"; |
3 | 3 |
|
| 4 | +import MiniCssExtractPlugin from "mini-css-extract-plugin"; |
| 5 | + |
4 | 6 | import { |
5 | 7 | compile, |
6 | 8 | getCompiler, |
7 | 9 | getErrors, |
8 | 10 | getExecutedCode, |
9 | 11 | getModuleSource, |
10 | 12 | getWarnings, |
| 13 | + readAsset, |
11 | 14 | } from "./helpers/index"; |
12 | 15 |
|
13 | 16 | describe('"url" option', () => { |
@@ -295,4 +298,51 @@ describe('"url" option', () => { |
295 | 298 | expect(getWarnings(stats)).toMatchSnapshot("warnings"); |
296 | 299 | expect(getErrors(stats, true)).toMatchSnapshot("errors"); |
297 | 300 | }); |
| 301 | + |
| 302 | + // Todo uncomment test when in MiniCssExtractPlugin will be applied fix for new URL syntax |
| 303 | + it.skip("should work with mini-css-extract-plugin", async () => { |
| 304 | + const compiler = getCompiler( |
| 305 | + "./url/MCEP.js", |
| 306 | + {}, |
| 307 | + { |
| 308 | + module: { |
| 309 | + rules: [ |
| 310 | + { |
| 311 | + test: /\.css$/i, |
| 312 | + use: [ |
| 313 | + { |
| 314 | + loader: MiniCssExtractPlugin.loader, |
| 315 | + options: { |
| 316 | + esModule: true, |
| 317 | + }, |
| 318 | + }, |
| 319 | + { |
| 320 | + loader: path.resolve(__dirname, "../src"), |
| 321 | + options: { |
| 322 | + esModule: true, |
| 323 | + }, |
| 324 | + }, |
| 325 | + ], |
| 326 | + }, |
| 327 | + { |
| 328 | + test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/i, |
| 329 | + type: "asset/resource", |
| 330 | + }, |
| 331 | + ], |
| 332 | + }, |
| 333 | + plugins: [ |
| 334 | + new MiniCssExtractPlugin({ |
| 335 | + filename: "[name].css", |
| 336 | + chunkFilename: "[id].css", |
| 337 | + }), |
| 338 | + ], |
| 339 | + } |
| 340 | + ); |
| 341 | + const stats = await compile(compiler); |
| 342 | + |
| 343 | + expect(readAsset("main.css", compiler, stats)).toMatchSnapshot("css"); |
| 344 | + expect(getModuleSource("./url/url.css", stats)).toMatchSnapshot("module"); |
| 345 | + expect(getWarnings(stats)).toMatchSnapshot("warnings"); |
| 346 | + expect(getErrors(stats)).toMatchSnapshot("errors"); |
| 347 | + }); |
298 | 348 | }); |
0 commit comments