|
| 1 | +import path from "path"; |
| 2 | + |
| 3 | +import MiniCssExtractPlugin from "../src/cjs"; |
| 4 | + |
| 5 | +import { compile, getCompiler } from "./helpers/index"; |
| 6 | + |
| 7 | +describe("pathinfo option", () => { |
| 8 | + it(`should insert pathinfo`, async () => { |
| 9 | + const compiler = getCompiler( |
| 10 | + "esm.js", |
| 11 | + {}, |
| 12 | + { |
| 13 | + mode: "none", |
| 14 | + output: { |
| 15 | + pathinfo: true, |
| 16 | + path: path.resolve(__dirname, "../outputs"), |
| 17 | + }, |
| 18 | + plugins: [ |
| 19 | + new MiniCssExtractPlugin({ |
| 20 | + filename: "[name].css", |
| 21 | + }), |
| 22 | + ], |
| 23 | + } |
| 24 | + ); |
| 25 | + const stats = await compile(compiler); |
| 26 | + const fs = stats.compilation.compiler.outputFileSystem; |
| 27 | + const extractedCss = fs |
| 28 | + .readFileSync(path.resolve(__dirname, "../outputs/main.css")) |
| 29 | + .toString(); |
| 30 | + |
| 31 | + expect(extractedCss).toMatch("./simple.css"); |
| 32 | + }); |
| 33 | + it(`should not insert pathinfo`, async () => { |
| 34 | + const compiler = getCompiler( |
| 35 | + "esm.js", |
| 36 | + {}, |
| 37 | + { |
| 38 | + mode: "none", |
| 39 | + output: { |
| 40 | + path: path.resolve(__dirname, "../outputs"), |
| 41 | + }, |
| 42 | + plugins: [ |
| 43 | + new MiniCssExtractPlugin({ |
| 44 | + filename: "[name].css", |
| 45 | + }), |
| 46 | + ], |
| 47 | + } |
| 48 | + ); |
| 49 | + const stats = await compile(compiler); |
| 50 | + const fs = stats.compilation.compiler.outputFileSystem; |
| 51 | + const extractedCss = fs |
| 52 | + .readFileSync(path.resolve(__dirname, "../outputs/main.css")) |
| 53 | + .toString(); |
| 54 | + |
| 55 | + expect(extractedCss).not.toMatch("./simple.css"); |
| 56 | + }); |
| 57 | +}); |
0 commit comments