Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support the
pathinfo
option (#783)
- Loading branch information
1 parent
9da806f
commit a37713f
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import path from "path"; | ||
|
||
import MiniCssExtractPlugin from "../src/cjs"; | ||
|
||
import { compile, getCompiler } from "./helpers/index"; | ||
|
||
describe("pathinfo option", () => { | ||
it(`should insert pathinfo`, async () => { | ||
const compiler = getCompiler( | ||
"esm.js", | ||
{}, | ||
{ | ||
mode: "none", | ||
output: { | ||
pathinfo: true, | ||
path: path.resolve(__dirname, "../outputs"), | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css", | ||
}), | ||
], | ||
} | ||
); | ||
const stats = await compile(compiler); | ||
const fs = stats.compilation.compiler.outputFileSystem; | ||
const extractedCss = fs | ||
.readFileSync(path.resolve(__dirname, "../outputs/main.css")) | ||
.toString(); | ||
|
||
expect(extractedCss).toMatch("./simple.css"); | ||
}); | ||
it(`should not insert pathinfo`, async () => { | ||
const compiler = getCompiler( | ||
"esm.js", | ||
{}, | ||
{ | ||
mode: "none", | ||
output: { | ||
path: path.resolve(__dirname, "../outputs"), | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css", | ||
}), | ||
], | ||
} | ||
); | ||
const stats = await compile(compiler); | ||
const fs = stats.compilation.compiler.outputFileSystem; | ||
const extractedCss = fs | ||
.readFileSync(path.resolve(__dirname, "../outputs/main.css")) | ||
.toString(); | ||
|
||
expect(extractedCss).not.toMatch("./simple.css"); | ||
}); | ||
}); |