Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add new extractor format for better accuracy - add attributes purge
- Loading branch information
Showing
30 changed files
with
715 additions
and
274 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"name": "vscode-jest-tests", | ||
"request": "launch", | ||
"args": [ | ||
"--runInBand" | ||
], | ||
"cwd": "${workspaceFolder}", | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"disableOptimisticBPs": true, | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
] | ||
} |
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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "2.0.1-alpha.0" | ||
"version": "2.0.0" | ||
} |
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 |
---|---|---|
@@ -1,31 +1,48 @@ | ||
import postcss from "postcss"; | ||
interface RawContent { | ||
extension: string; | ||
raw: string; | ||
extension: string; | ||
raw: string; | ||
} | ||
interface RawCSS { | ||
raw: string; | ||
raw: string; | ||
} | ||
declare type ExtractorFunction = (content: string) => string[]; | ||
interface Extractors { | ||
extensions: string[]; | ||
extractor: ExtractorFunction; | ||
extensions: string[]; | ||
extractor: ExtractorFunction; | ||
} | ||
interface UserDefinedOptions { | ||
content: Array<string | RawContent>; | ||
css: Array<string | RawCSS>; | ||
defaultExtractor?: ExtractorFunction; | ||
extractors?: Array<Extractors>; | ||
fontFace?: boolean; | ||
keyframes?: boolean; | ||
output?: string; | ||
rejected?: boolean; | ||
stdin?: boolean; | ||
stdout?: boolean; | ||
variables?: boolean; | ||
whitelist?: string[]; | ||
whitelistPatterns?: Array<RegExp>; | ||
whitelistPatternsChildren?: Array<RegExp>; | ||
content: Array<string | RawContent>; | ||
css: Array<string | RawCSS>; | ||
defaultExtractor?: ExtractorFunction; | ||
extractors?: Array<Extractors>; | ||
fontFace?: boolean; | ||
keyframes?: boolean; | ||
output?: string; | ||
rejected?: boolean; | ||
stdin?: boolean; | ||
stdout?: boolean; | ||
variables?: boolean; | ||
whitelist?: string[]; | ||
whitelistPatterns?: Array<RegExp>; | ||
whitelistPatternsChildren?: Array<RegExp>; | ||
} | ||
declare const purgeCSSPlugin: postcss.Plugin<Pick<UserDefinedOptions, "content" | "defaultExtractor" | "extractors" | "fontFace" | "keyframes" | "output" | "rejected" | "stdin" | "stdout" | "variables" | "whitelist" | "whitelistPatterns" | "whitelistPatternsChildren">>; | ||
declare const purgeCSSPlugin: postcss.Plugin< | ||
Pick< | ||
UserDefinedOptions, | ||
| "content" | ||
| "defaultExtractor" | ||
| "extractors" | ||
| "fontFace" | ||
| "keyframes" | ||
| "output" | ||
| "rejected" | ||
| "stdin" | ||
| "stdout" | ||
| "variables" | ||
| "whitelist" | ||
| "whitelistPatterns" | ||
| "whitelistPatternsChildren" | ||
> | ||
>; | ||
export default purgeCSSPlugin; |
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 |
---|---|---|
@@ -1,31 +1,48 @@ | ||
import postcss from "postcss"; | ||
interface RawContent { | ||
extension: string; | ||
raw: string; | ||
extension: string; | ||
raw: string; | ||
} | ||
interface RawCSS { | ||
raw: string; | ||
raw: string; | ||
} | ||
declare type ExtractorFunction = (content: string) => string[]; | ||
interface Extractors { | ||
extensions: string[]; | ||
extractor: ExtractorFunction; | ||
extensions: string[]; | ||
extractor: ExtractorFunction; | ||
} | ||
interface UserDefinedOptions { | ||
content: Array<string | RawContent>; | ||
css: Array<string | RawCSS>; | ||
defaultExtractor?: ExtractorFunction; | ||
extractors?: Array<Extractors>; | ||
fontFace?: boolean; | ||
keyframes?: boolean; | ||
output?: string; | ||
rejected?: boolean; | ||
stdin?: boolean; | ||
stdout?: boolean; | ||
variables?: boolean; | ||
whitelist?: string[]; | ||
whitelistPatterns?: Array<RegExp>; | ||
whitelistPatternsChildren?: Array<RegExp>; | ||
content: Array<string | RawContent>; | ||
css: Array<string | RawCSS>; | ||
defaultExtractor?: ExtractorFunction; | ||
extractors?: Array<Extractors>; | ||
fontFace?: boolean; | ||
keyframes?: boolean; | ||
output?: string; | ||
rejected?: boolean; | ||
stdin?: boolean; | ||
stdout?: boolean; | ||
variables?: boolean; | ||
whitelist?: string[]; | ||
whitelistPatterns?: Array<RegExp>; | ||
whitelistPatternsChildren?: Array<RegExp>; | ||
} | ||
declare const purgeCSSPlugin: postcss.Plugin<Pick<UserDefinedOptions, "content" | "defaultExtractor" | "extractors" | "fontFace" | "keyframes" | "output" | "rejected" | "stdin" | "stdout" | "variables" | "whitelist" | "whitelistPatterns" | "whitelistPatternsChildren">>; | ||
declare const purgeCSSPlugin: postcss.Plugin< | ||
Pick< | ||
UserDefinedOptions, | ||
| "content" | ||
| "defaultExtractor" | ||
| "extractors" | ||
| "fontFace" | ||
| "keyframes" | ||
| "output" | ||
| "rejected" | ||
| "stdin" | ||
| "stdout" | ||
| "variables" | ||
| "whitelist" | ||
| "whitelistPatterns" | ||
| "whitelistPatternsChildren" | ||
> | ||
>; | ||
export default purgeCSSPlugin; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export const TEST_1_CONTENT = ` | ||
<html> | ||
<head> | ||
<title>App Name - @yield('title')</title> | ||
</head> | ||
<body> | ||
@section('sidebar') | ||
This is the master sidebar. | ||
@show | ||
<div class="test-container"> | ||
@yield('content') | ||
</div> | ||
@if (count($records) === 1) | ||
<a href="#" id="a-link" class="a-link"></a> | ||
@else | ||
<input id="blo" type="text" disabled/> | ||
@endif | ||
<div class="test-footer"></div> | ||
</body> | ||
</html> | ||
`; | ||
|
||
export const TEST_1_TAG = [ | ||
"html", | ||
"head", | ||
"title", | ||
"body", | ||
"div", | ||
"a", | ||
"input" | ||
]; | ||
|
||
export const TEST_1_CLASS = ["test-container", "test-footer", "a-link"]; | ||
|
||
export const TEST_1_ID = ["a-link", "blo"]; |
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,36 @@ | ||
import purgeBlade from "../src/index"; | ||
|
||
import { TEST_1_CONTENT, TEST_1_TAG, TEST_1_CLASS, TEST_1_ID } from "./data"; | ||
|
||
describe("purge-from-blade", () => { | ||
describe("from a normal blade document", () => { | ||
it("finds tag selectors", () => { | ||
const received = purgeBlade(TEST_1_CONTENT); | ||
for (let item of TEST_1_TAG) { | ||
expect(received.includes(item)).toBe(true); | ||
} | ||
}); | ||
|
||
it("finds classes selectors", () => { | ||
const received = purgeBlade(TEST_1_CONTENT); | ||
for (let item of TEST_1_CLASS) { | ||
expect(received.includes(item)).toBe(true); | ||
} | ||
}); | ||
|
||
it("finds id selectors", () => { | ||
const received = purgeBlade(TEST_1_CONTENT); | ||
for (let item of TEST_1_ID) { | ||
expect(received.includes(item)).toBe(true); | ||
} | ||
}); | ||
|
||
it("finds all selectors", () => { | ||
const received = purgeBlade(TEST_1_CONTENT); | ||
const selectors = [...TEST_1_TAG, ...TEST_1_CLASS, ...TEST_1_ID]; | ||
for (let item of selectors) { | ||
expect(received.includes(item)).toBe(true); | ||
} | ||
}); | ||
}); | ||
}); |
7 changes: 0 additions & 7 deletions
7
packages/purgecss-from-blade/__tests__/purgecss-from-blade.test.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import { Compiler, Source } from "@tarik02/bladejs-compiler"; |
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
Oops, something went wrong.