-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(purgecss) #905
Merged
Merged
fix(purgecss) #905
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d116bf
fix(purgecss) general improvements. fix binds.
kellymears 0d6020b
test(purgecss) add unit tests
kellymears be1124e
test(purgecss) add integration tests
kellymears 9222b25
examples(purgecss) add example/purgecss
kellymears 110179a
fix(tsdoc) add @todo tag
kellymears aecbe62
fix(tsdoc) @todo is a block tag
kellymears 91d7aa5
yarn.lock
kellymears File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,5 @@ | ||
node_modules | ||
dist | ||
|
||
# You probably will want to remove these entries | ||
.bud |
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,8 @@ | ||
module.exports = app => | ||
app | ||
.template({template: 'public/index.html'}) | ||
.entry({app: 'app.css'}) | ||
.purgecss({ | ||
content: [app.path('project', 'public', '*.html')], | ||
css: [app.path('src', '**', '*.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,5 @@ | ||
{ | ||
"typeAcquisition": { | ||
"enable": true | ||
} | ||
} |
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,26 @@ | ||
{ | ||
"name": "example-purgecss", | ||
"private": true, | ||
"browserslist": { | ||
"production": [ | ||
">0.5%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@fullhuman/postcss-purgecss": "4.1.3", | ||
"@roots/bud": "workspace:*", | ||
"@roots/bud-postcss": "workspace:*", | ||
"@roots/bud-purgecss": "workspace:*", | ||
"postcss": "8.4.5", | ||
"postcss-import": "14.0.2", | ||
"postcss-nested": "5.0.6", | ||
"postcss-preset-env": "7.1.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1" | ||
/> | ||
|
||
<title>%APP_TITLE%</title> | ||
<meta name="theme-color" content="%APP_COLOR%" /> | ||
<meta name="description" content="%APP_DESCRIPTION%" /> | ||
</head> | ||
|
||
<body> | ||
<h1>PostCSS</h1> | ||
<h2>PurgeCss test</h2> | ||
</body> | ||
</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 @@ | ||
@import 'main'; |
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 @@ | ||
h1 { | ||
color: black; | ||
} | ||
|
||
h2 { | ||
color: red; | ||
} | ||
|
||
h3.exclude { | ||
color: yellow; | ||
} |
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,13 @@ | ||
import {Extension} from '@roots/bud-framework' | ||
|
||
import * as purge from './purge.interface' | ||
|
||
declare module '@roots/bud-framework' { | ||
interface Framework { | ||
purgecss: purge.api | ||
} | ||
|
||
interface Modules { | ||
'@roots/bud-purgecss': Extension.Module | ||
} | ||
} |
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,87 @@ | ||
import {Extension, Framework} from '@roots/bud-framework' | ||
|
||
/** | ||
* Module registration | ||
* | ||
* @public | ||
*/ | ||
export interface register { | ||
(app: Framework): Promise<void> | ||
} | ||
|
||
/** | ||
* Purge unused CSS from compiled stylesheets | ||
* | ||
* @remarks | ||
* For more information, see [the PurgeCSS API](https://purgecss.com/configuration.html) | ||
* | ||
* @example | ||
* ```js | ||
* app.purgecss({ | ||
* content: [app.path('project', 'resources/views/**')], | ||
* allow: require('purgecss-with-wordpress').whitelist, | ||
* allowPatterns: require('purgecss-with-wordpress').whitelistPatterns, | ||
* }) | ||
* ``` | ||
*/ | ||
export interface api { | ||
(this: Framework, userOptions: UserOptions): Framework | ||
} | ||
|
||
export interface Purge extends Extension.Module { | ||
name: string | ||
register: register | ||
api: {purgecss: api} | ||
} | ||
|
||
/** | ||
* PurgeCSS UserOptions | ||
* | ||
* @see https://purgecss.com/plugins/postcss.html#options | ||
* | ||
* @public | ||
*/ | ||
export interface UserOptions { | ||
content?: Array< | ||
| string | ||
| { | ||
extension: string | ||
raw: string | ||
} | ||
> | ||
contentFunction?: (sourceFile: string) => Array< | ||
| string | ||
| { | ||
extension: string | ||
raw: string | ||
} | ||
> | ||
defaultExtractor?: ExtractorFunction | ||
extractors?: Array<Extractors> | ||
fontFace?: boolean | ||
keyframes?: boolean | ||
output?: string | ||
rejected?: boolean | ||
stdin?: boolean | ||
stdout?: boolean | ||
variables?: boolean | ||
safelist?: | ||
| { | ||
standard?: Array<RegExp | string> | ||
deep?: RegExp[] | ||
greedy?: RegExp[] | ||
variables?: Array<RegExp | string> | ||
keyframes?: Array<RegExp | string> | ||
} | ||
| Array<RegExp | string> | ||
blocklist?: Array<RegExp | string> | ||
} | ||
|
||
export type ExtractorFunction<T = string> = ( | ||
content: T, | ||
) => string[] | ||
|
||
export interface Extractors { | ||
extensions: string[] | ||
extractor: ExtractorFunction | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason for this
register
callback is that I need to set/bind the facade forbud.config.js
.this should eventually be moved to
@roots/bud-extensions/src/Controller/controller.service.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressing this in #906. let's get that merged first and then I can remove this.