-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Ability to Ignore Files/Folders (#638)
* Add Skiplist Option Adds support for the "ignore" option of the glob dependency to prevent PurgeCSS from scanning specific folders (such as node_modules, etc.) * Update Readme Add description for new "skippedlist" option * Rename Option, Fix Type Replaced "skiplist" with "skippedContentGlobs" and changed the type to Array<String> * Rename Option, Fix Type Replaced "skiplist" with "skippedContentGlobs" and changed the type to Array<String> * Add Skipped-Content Test test for "skippedContentGlobs" added, casing on 'string' type fixed. Test passes, but only with full path to file to skip right now. * Fix test Use the correct path for the test environment * Update Docs Minor documentation tweaks Co-authored-by: Bryan Jones <bryan@codekitapp.com> Co-authored-by: Floriel <Ffloriel@users.noreply.github.com>
- Loading branch information
1 parent
9b0fdc3
commit 2a27663
Showing
10 changed files
with
67 additions
and
4 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
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,24 @@ | ||
import PurgeCSS from "./../src/index"; | ||
|
||
import { ROOT_TEST_EXAMPLES } from "./utils"; | ||
|
||
describe("skipped-content", () => { | ||
let purgedCSS: string; | ||
|
||
beforeAll(async () => { | ||
const resultsPurge = await new PurgeCSS().purge({ | ||
content: [`${ROOT_TEST_EXAMPLES}skipped-content/**/*.html`], | ||
css: [`${ROOT_TEST_EXAMPLES}skipped-content/simple.css`], | ||
skippedContentGlobs: [ | ||
`${ROOT_TEST_EXAMPLES}skipped-content/skippedFolder/**`, | ||
], | ||
}); | ||
purgedCSS = resultsPurge[0].css; | ||
}); | ||
|
||
it("purges appropriate CSS rules when skippedContentGlobs is set", () => { | ||
expect(purgedCSS.includes(".red")).toBe(true); | ||
expect(purgedCSS.includes(".black")).toBe(true); | ||
expect(purgedCSS.includes(".green")).toBe(false); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/purgecss/__tests__/test_examples/skipped-content/simple.css
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,11 @@ | ||
.black { | ||
color: black; | ||
} | ||
|
||
.red { | ||
color: red; | ||
} | ||
|
||
.green { | ||
color: green; | ||
} |
1 change: 1 addition & 0 deletions
1
packages/purgecss/__tests__/test_examples/skipped-content/skippedFolder/skipped.html
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 @@ | ||
<p class="green">anything</p> |
2 changes: 2 additions & 0 deletions
2
packages/purgecss/__tests__/test_examples/skipped-content/unskipped.html
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,2 @@ | ||
<p class="black">anything</p> | ||
<p class="red">anything</p> |
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
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