Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: ignore plugin
  • Loading branch information
alexander-akait committed Jul 14, 2021
commit 8ce9ab561b88cc88493f7d1247fc96f3866d9336
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ npm-debug.log*
/local
/reports
/node_modules
/test/outputs
/test/fixtures/import/import-absolute.css
/test/fixtures/url/url-absolute.css
/test/fixtures/modules/composes/composes-absolute.css
Expand Down
70 changes: 70 additions & 0 deletions test/fixtures/url/ignore-plugin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Unknown
*/
div {
background: url("/assets/unknown.png");
}

div {
background: url("./assets/unknown.png");
}

div {
background: url("assets/unknown.png");
}

div {
background: url("/unknwon.png");
}

div {
background: url("./unknwon.png");
}

div {
background: url("unknwon.png");
}

/*
Known
*/

div {
background: url("/nested/img.png");
}

div {
background: url("./nested/img.png");
}

div {
background: url("./nested/img.png");
}

div {
background: url("/img.png");
}

div {
background: url("./img.png");
}

div {
background: url("img.png");
}

/*
Directory
*/

div {
background: url("/directory/unknown.png");
}

div {
background: url("./directory/unknown.png");
}

div {
background: url("directory/unknown.png");
}
5 changes: 5 additions & 0 deletions test/fixtures/url/ignore-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import css from './ignore-plugin.css';

__export__ = css;

export default css;
24 changes: 24 additions & 0 deletions test/url-option.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import fs from "fs";
import path from "path";

import webpack from "webpack";

import MiniCssExtractPlugin from "mini-css-extract-plugin";

import {
Expand Down Expand Up @@ -378,4 +380,26 @@ describe('"url" option', () => {
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});

// TODO bug on webpack side
it.skip("should work with the 'IgnorePlugin' plugin", async () => {
const compiler = getCompiler("./url/ignore-plugin.js");

new webpack.IgnorePlugin({ resourceRegExp: /directory\// }).apply(compiler);
new webpack.IgnorePlugin({ resourceRegExp: /unknwon\.png/ }).apply(
compiler
);
new webpack.IgnorePlugin({ resourceRegExp: /img\.png/ }).apply(compiler);

const stats = await compile(compiler);

expect(getModuleSource("./url/ignore-plugin.css", stats)).toMatchSnapshot(
"module"
);
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
"result"
);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});