Skip to content

Commit fd7b91a

Browse files
committed
chore(scripts) create build script
1 parent 2b0616f commit fd7b91a

28 files changed

+497
-60
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"devDependencies": {
55
"@types/jest": "^24.0.18",
66
"@types/node": "^12.7.11",
7+
"@wessberg/rollup-plugin-ts": "^1.1.65",
78
"jest": "^24.9.0",
89
"lerna": "^3.14.1",
910
"lint-staged": "^9.4.2",
1011
"prettier": "^1.18.2",
1112
"rollup": "^1.23.1",
1213
"rollup-plugin-node-resolve": "^5.2.0",
1314
"rollup-plugin-terser": "^5.1.2",
14-
"rollup-plugin-typescript2": "^0.24.3",
1515
"ts-jest": "^24.1.0",
1616
"ts-node": "^8.4.1",
1717
"typescript": "^3.6.3"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import postcss from "postcss";
2+
interface RawContent {
3+
extension: string;
4+
raw: string;
5+
}
6+
interface RawCSS {
7+
raw: string;
8+
}
9+
declare type ExtractorFunction = (content: string) => string[];
10+
interface Extractors {
11+
extensions: string[];
12+
extractor: ExtractorFunction;
13+
}
14+
interface UserDefinedOptions {
15+
content: Array<string | RawContent>;
16+
css: Array<string | RawCSS>;
17+
defaultExtractor?: ExtractorFunction;
18+
extractors?: Array<Extractors>;
19+
fontFace?: boolean;
20+
keyframes?: boolean;
21+
output?: string;
22+
rejected?: boolean;
23+
stdin?: boolean;
24+
stdout?: boolean;
25+
variables?: boolean;
26+
whitelist?: string[];
27+
whitelistPatterns?: Array<RegExp>;
28+
whitelistPatternsChildren?: Array<RegExp>;
29+
}
30+
declare const purgeCSSPlugin: postcss.Plugin<Pick<UserDefinedOptions, "content" | "defaultExtractor" | "extractors" | "fontFace" | "keyframes" | "output" | "rejected" | "stdin" | "stdout" | "variables" | "whitelist" | "whitelistPatterns" | "whitelistPatternsChildren">>;
31+
export default purgeCSSPlugin;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import postcss from "postcss";
2+
interface RawContent {
3+
extension: string;
4+
raw: string;
5+
}
6+
interface RawCSS {
7+
raw: string;
8+
}
9+
declare type ExtractorFunction = (content: string) => string[];
10+
interface Extractors {
11+
extensions: string[];
12+
extractor: ExtractorFunction;
13+
}
14+
interface UserDefinedOptions {
15+
content: Array<string | RawContent>;
16+
css: Array<string | RawCSS>;
17+
defaultExtractor?: ExtractorFunction;
18+
extractors?: Array<Extractors>;
19+
fontFace?: boolean;
20+
keyframes?: boolean;
21+
output?: string;
22+
rejected?: boolean;
23+
stdin?: boolean;
24+
stdout?: boolean;
25+
variables?: boolean;
26+
whitelist?: string[];
27+
whitelistPatterns?: Array<RegExp>;
28+
whitelistPatternsChildren?: Array<RegExp>;
29+
}
30+
declare const purgeCSSPlugin: postcss.Plugin<Pick<UserDefinedOptions, "content" | "defaultExtractor" | "extractors" | "fontFace" | "keyframes" | "output" | "rejected" | "stdin" | "stdout" | "variables" | "whitelist" | "whitelistPatterns" | "whitelistPatternsChildren">>;
31+
export default purgeCSSPlugin;

packages/postcss-purgecss/lib/postcss-purgecss.esm.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/postcss-purgecss/lib/postcss-purgecss.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/postcss-purgecss/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"homepage": "https://github.com/FullHuman/purgecss#readme",
77
"license": "ISC",
88
"main": "lib/postcss-purgecss.js",
9+
"module": "lib/postcss-purgecss.esm.js",
10+
"types": "lib/postcss-purgecss.d.ts",
911
"directories": {
1012
"lib": "lib",
1113
"test": "__tests__"
@@ -26,5 +28,6 @@
2628
"dependencies": {
2729
"postcss": "^7.0.18",
2830
"purgecss": "^2.0.0"
29-
}
31+
},
32+
"publishConfig": { "registry": "https://npm.pkg.github.com/" }
3033
}

packages/postcss-purgecss/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import postcss from "postcss";
22
import {
33
walkThroughCSS,
4+
defaultOptions,
45
extractSelectorsFromFiles,
56
extractSelectorsFromString,
67
setPurgeCSSOptions,
78
removeUnusedFontFaces,
89
removeUnusedKeyframes,
910
selectorsRemoved
10-
} from "purgecss/src/index";
11-
import { RawContent, UserDefinedOptions } from "purgecss/src/types";
12-
import { defaultOptions } from "purgecss/src/options";
11+
} from "purgecss";
12+
13+
import {
14+
RawContent,
15+
UserDefinedOptions
16+
} from './types'
1317

1418
type PurgeCSSPostCSSOptions = Omit<UserDefinedOptions, "css">;
1519

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export interface RawContent {
2+
extension: string;
3+
raw: string;
4+
}
5+
export interface RawCSS {
6+
raw: string;
7+
}
8+
type ExtractorFunction = (content: string) => string[];
9+
export interface Extractors {
10+
extensions: string[];
11+
extractor: ExtractorFunction;
12+
}
13+
export interface UserDefinedOptions {
14+
content: Array<string | RawContent>;
15+
css: Array<string | RawCSS>;
16+
defaultExtractor?: ExtractorFunction;
17+
extractors?: Array<Extractors>;
18+
fontFace?: boolean;
19+
keyframes?: boolean;
20+
output?: string;
21+
rejected?: boolean;
22+
stdin?: boolean;
23+
stdout?: boolean;
24+
variables?: boolean;
25+
whitelist?: string[];
26+
whitelistPatterns?: Array<RegExp>;
27+
whitelistPatternsChildren?: Array<RegExp>;
28+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare const purgecssFromHtml: (content: string) => string[];
2+
export default purgecssFromHtml;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare const purgecssFromHtml: (content: string) => string[];
2+
export default purgecssFromHtml;

packages/purgecss-from-html/lib/purgecss-from-html.esm.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/purgecss-from-html/lib/purgecss-from-html.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/purgecss-from-html/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
"devDependencies": {
3131
"@types/parse5": "^5.0.2",
3232
"@types/parse5-htmlparser2-tree-adapter": "^5.0.1"
33-
}
33+
},
34+
"publishConfig": { "registry": "https://npm.pkg.github.com/" }
3435
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare const purgeFromPug: (content: string) => string[];
2+
export default purgeFromPug;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare const purgeFromPug: (content: string) => string[];
2+
export default purgeFromPug;

packages/purgecss-from-pug/lib/purgecss-from-pug.esm.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/purgecss-from-pug/lib/purgecss-from-pug.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/purgecss-from-pug/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purgecss-from-pug",
3-
"version": "0.0.0",
3+
"version": "2.0.0",
44
"description": "> TODO: description",
55
"author": "Ffloriel <florielfedry@gmail.com>",
66
"homepage": "https://github.com/FullHuman/purgecss#readme",
@@ -26,5 +26,6 @@
2626
"devDependencies": {
2727
"pug-lexer": "^4.1.0",
2828
"pug-parser": "^5.0.1"
29-
}
29+
},
30+
"publishConfig": { "registry": "https://npm.pkg.github.com/" }
3031
}

packages/purgecss/README.md

Lines changed: 111 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,119 @@
1-
# `purgecss`
1+
# PurgeCSS
22

3-
> TODO: description
3+
[![Build Status](https://travis-ci.org/FullHuman/purgecss.svg?branch=master)](https://travis-ci.org/FullHuman/purgecss)
4+
[![CircleCi](https://circleci.com/gh/FullHuman/purgecss/tree/master.svg?style=shield)]()
5+
[![dependencies Status](https://david-dm.org/fullhuman/purgecss/status.svg)](https://david-dm.org/fullhuman/purgecss)
6+
[![devDependencies Status](https://david-dm.org/fullhuman/purgecss/dev-status.svg)](https://david-dm.org/fullhuman/purgecss?type=dev)
7+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2f2f3fb0a5c541beab2018483e62a828)](https://www.codacy.com/app/FullHuman/purgecss?utm_source=github.com&utm_medium=referral&utm_content=FullHuman/purgecss&utm_campaign=Badge_Grade)
8+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/2f2f3fb0a5c541beab2018483e62a828)](https://www.codacy.com/app/FullHuman/purgecss?utm_source=github.com&utm_medium=referral&utm_content=FullHuman/purgecss&utm_campaign=Badge_Coverage)
9+
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
10+
[![npm](https://img.shields.io/npm/v/purgecss.svg)](https://www.npmjs.com/package/purgecss)
11+
[![license](https://img.shields.io/github/license/fullhuman/purgecss.svg)]() [![Greenkeeper badge](https://badges.greenkeeper.io/FullHuman/purgecss.svg)](https://greenkeeper.io/)
12+
13+
<p align="center">
14+
<img src="./.assets/logo.png" height="200" width="200" alt="PurgeCSS logo"/>
15+
</p>
16+
17+
## What is PurgeCSS?
18+
19+
When you are building a website, chances are that you are using a css framework
20+
like Bootstrap, Materializecss, Foundation, etc... But you will only use a small
21+
set of the framework and a lot of unused css styles will be included.
22+
23+
This is where PurgeCSS comes into play. PurgeCSS analyzes your content and your
24+
css files. Then it matches the selectors used in your files with the one in your
25+
content files. It removes unused selectors from your css, resulting in smaller
26+
css files.
27+
28+
## Documentation
29+
30+
You can find the PurgeCSS documentation
31+
[on this website](https://www.purgecss.com).
32+
33+
* [Configuration](https://www.purgecss.com/configuration)
34+
* [CLI](https://www.purgecss.com/cli)
35+
* [Javascript API](https://www.purgecss.com/javascript-api)
36+
* [Webpack plugin](https://www.purgecss.com/with-webpack)
37+
* [Gulp plugin](https://www.purgecss.com/with-gulp)
38+
* [Grunt plugin](https://www.purgecss.com/with-grunt)
39+
* [Rollup plugin](https://www.purgecss.com/with-rollup)
40+
* [Whitelisting](https://www.purgecss.com/whitelisting)
41+
* [Extractors](https://www.purgecss.com/extractors)
42+
* [Comparison](https://www.purgecss.com/comparison)
43+
* Guides
44+
* [React](https://www.purgecss.com/guides/react)
45+
* [Vue](https://www.purgecss.com/guides/vue)
46+
* [Nuxt](https://www.purgecss.com/guides/nuxt)
47+
* [Wordpress](https://www.purgecss.com/guides/wordpress)
48+
49+
## Getting Started
50+
51+
#### Installation
52+
53+
```
54+
npm i --save-dev purgecss
55+
```
456

557
## Usage
658

59+
```js
60+
import Purgecss from 'purgecss'
61+
const purgeCss = new Purgecss({
62+
content: ['**/*.html'],
63+
css: ['**/*.css']
64+
})
65+
const result = purgeCss.purge()
766
```
8-
npm -g i purgecss
967

10-
purgecss --help
68+
With a custom extractor:
1169

12-
// TODO: DEMONSTRATE API
70+
```js
71+
import purgeCSS from 'purgecss'
72+
import purgeHtml from 'purgecss-from-html'
73+
const result = await purgeCSS({
74+
content: ['**/*.html'],
75+
css: ['**/*.css'],
76+
extractors: [
77+
{
78+
extractor: purgeHtml,
79+
extensions: ['html']
80+
}
81+
]
82+
})
1383
```
84+
85+
### Build Plugin
86+
87+
<div align="center">
88+
<a href="https://github.com/FullHuman/purgecss-webpack-plugin">
89+
<img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
90+
</a>
91+
<a href="https://github.com/FullHuman/gulp-purgecss">
92+
<img height="200" width="89" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
93+
</a>
94+
<a href="https://github.com/FullHuman/grunt-purgecss">
95+
<img height="200" width="200" src="https://gruntjs.com/img/grunt-logo-no-wordmark.svg">
96+
</a>
97+
<a href="https://github.com/FullHuman/rollup-plugin-purgecss">
98+
<img height="200" width="200" src="https://rollupjs.org/logo.svg"/>
99+
</a>
100+
</div>
101+
102+
* [Webpack](https://www.purgecss.com/with-webpack)
103+
* [Gulp](https://www.purgecss.com/with-gulp)
104+
* [Grunt](https://www.purgecss.com/with-grunt)
105+
* [Rollup](https://www.purgecss.com/with-rollup)
106+
107+
## Contributing
108+
109+
Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of
110+
conduct, and the process for submitting pull requests to us.
111+
112+
## Versioning
113+
114+
PurgeCSS use [SemVer](http://semver.org/) for versioning.
115+
116+
## License
117+
118+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
119+
for details.

0 commit comments

Comments
 (0)