rollup-plugin-purgecss 1.0.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +7 -5
- package/__tests__/assets/actual_a.css +7 -1
- package/__tests__/assets/expect_a.css +8 -1
- package/__tests__/assets/test_a.css +12 -0
- package/__tests__/fixtures/basic/index.js +4 -4
- package/__tests__/index.test.ts +27 -0
- package/lib/rollup-plugin-purgecss.d.ts +43 -0
- package/lib/rollup-plugin-purgecss.esm.d.ts +43 -0
- package/lib/rollup-plugin-purgecss.esm.js +1 -0
- package/lib/rollup-plugin-purgecss.js +1 -64
- package/package.json +13 -21
- package/src/index.ts +71 -0
- package/src/types/index.ts +42 -0
- package/.circleci/config.yml +0 -16
- package/.eslintrc +0 -13
- package/.github/CODE_OF_CONDUCT.md +0 -46
- package/.github/ISSUE_TEMPLATE.md +0 -13
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -24
- package/.travis.yml +0 -3
- package/CONTRIBUTING.md +0 -42
- package/__tests__/assets/actual_b.css +0 -1
- package/__tests__/assets/actual_c.css +0 -1
- package/__tests__/assets/actual_d.css +0 -0
- package/__tests__/assets/actual_e.css +0 -0
- package/__tests__/assets/expect_b.css +0 -1
- package/__tests__/assets/expect_c.css +0 -1
- package/__tests__/assets/expect_d.css +0 -1
- package/__tests__/assets/expect_e.css +0 -1
- package/__tests__/fixtures/compress/index.js +0 -3
- package/__tests__/fixtures/data/index.js +0 -3
- package/__tests__/fixtures/insert/index.js +0 -2
- package/__tests__/fixtures/output-function/index.js +0 -2
- package/__tests__/fixtures/output-path/index.js +0 -2
- package/__tests__/fixtures/output-true/index.js +0 -2
- package/__tests__/fixtures/processor/index.js +0 -4
- package/__tests__/fixtures/processor-promise/index.js +0 -4
- package/__tests__/fixtures/ts-basic/index.ts +0 -6
- package/__tests__/fixtures/ts-output-function/index.ts +0 -2
- package/__tests__/fixtures/ts-output-path/index.ts +0 -2
- package/__tests__/fixtures/ts-output-true/index.ts +0 -2
- package/__tests__/index.test.js +0 -31
- package/lib/rollup-plugin-purgecss.es.js +0 -60
- package/rollup.config.js +0 -25
- package/src/index.js +0 -62
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# rollup-plugin-purgecss
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
6
8
|
|
|
7
9
|
[Rollup](https://github.com/rollup/rollup) plugin to remove unused css.
|
|
8
10
|
|
|
@@ -30,7 +32,7 @@ rollup({
|
|
|
30
32
|
|
|
31
33
|
## Contributing
|
|
32
34
|
|
|
33
|
-
Please read [CONTRIBUTING.md](
|
|
35
|
+
Please read [CONTRIBUTING.md](./../../CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
|
34
36
|
|
|
35
37
|
## Versioning
|
|
36
38
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import actualB from '../../assets/actual_b.css'
|
|
3
|
-
import actualC from '../../assets/actual_c.css'
|
|
1
|
+
import "../../assets/test_a.css";
|
|
4
2
|
|
|
5
|
-
export default
|
|
3
|
+
export default function noop() {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { rollup } from "rollup";
|
|
4
|
+
import purgecss from "./../src/";
|
|
5
|
+
|
|
6
|
+
describe("rollup-plugin-purgecss", () => {
|
|
7
|
+
it("remove unused css", async () => {
|
|
8
|
+
const bundle = await rollup({
|
|
9
|
+
input: path.resolve(__dirname, "fixtures/basic/index.js"),
|
|
10
|
+
plugins: [
|
|
11
|
+
purgecss({
|
|
12
|
+
content: [path.resolve(__dirname, "assets/test_a.html")],
|
|
13
|
+
output: path.resolve(__dirname, "assets/actual_a.css"),
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
await bundle.generate({ format: "cjs", exports: "auto" });
|
|
18
|
+
|
|
19
|
+
const actualA = fs
|
|
20
|
+
.readFileSync(path.resolve(__dirname, "assets/actual_a.css"))
|
|
21
|
+
.toString();
|
|
22
|
+
const expectA = fs
|
|
23
|
+
.readFileSync(path.resolve(__dirname, "assets/expect_a.css"))
|
|
24
|
+
.toString();
|
|
25
|
+
expect(actualA).toEqual(expectA);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Plugin } from "rollup";
|
|
2
|
+
type StringRegExpArray = Array<RegExp | string>;
|
|
3
|
+
type ComplexSafelist = {
|
|
4
|
+
standard?: StringRegExpArray;
|
|
5
|
+
deep?: RegExp[];
|
|
6
|
+
greedy?: RegExp[];
|
|
7
|
+
variables?: StringRegExpArray;
|
|
8
|
+
keyframes?: StringRegExpArray;
|
|
9
|
+
};
|
|
10
|
+
type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
|
11
|
+
interface RawContent$0<T = string> {
|
|
12
|
+
extension: string;
|
|
13
|
+
raw: T;
|
|
14
|
+
}
|
|
15
|
+
type ExtractorFunction$0<T = string> = (content: T) => string[];
|
|
16
|
+
interface Extractors$0 {
|
|
17
|
+
extensions: string[];
|
|
18
|
+
extractor: ExtractorFunction$0;
|
|
19
|
+
}
|
|
20
|
+
type OutputFunction = (css: string, styles: string[]) => void;
|
|
21
|
+
interface UserDefinedOptions$0 {
|
|
22
|
+
content: Array<string | RawContent$0>;
|
|
23
|
+
contentFunction?: (sourceFile: string) => Array<string | RawContent$0>;
|
|
24
|
+
defaultExtractor?: ExtractorFunction$0;
|
|
25
|
+
extractors?: Array<Extractors$0>;
|
|
26
|
+
fontFace?: boolean;
|
|
27
|
+
keyframes?: boolean;
|
|
28
|
+
output?: string | OutputFunction | boolean;
|
|
29
|
+
rejected?: boolean;
|
|
30
|
+
stdin?: boolean;
|
|
31
|
+
stdout?: boolean;
|
|
32
|
+
variables?: boolean;
|
|
33
|
+
safelist?: UserDefinedSafelist;
|
|
34
|
+
blocklist?: StringRegExpArray;
|
|
35
|
+
skippedContentGlobs?: Array<string>;
|
|
36
|
+
dynamicAttributes?: string[];
|
|
37
|
+
insert?: boolean;
|
|
38
|
+
include?: string | RegExp | (string | RegExp)[];
|
|
39
|
+
exclude?: string | RegExp | (string | RegExp)[];
|
|
40
|
+
dest?: string;
|
|
41
|
+
}
|
|
42
|
+
declare function pluginPurgeCSS(options: UserDefinedOptions$0): Plugin;
|
|
43
|
+
export { pluginPurgeCSS as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Plugin } from "rollup";
|
|
2
|
+
type StringRegExpArray = Array<RegExp | string>;
|
|
3
|
+
type ComplexSafelist = {
|
|
4
|
+
standard?: StringRegExpArray;
|
|
5
|
+
deep?: RegExp[];
|
|
6
|
+
greedy?: RegExp[];
|
|
7
|
+
variables?: StringRegExpArray;
|
|
8
|
+
keyframes?: StringRegExpArray;
|
|
9
|
+
};
|
|
10
|
+
type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
|
11
|
+
interface RawContent$0<T = string> {
|
|
12
|
+
extension: string;
|
|
13
|
+
raw: T;
|
|
14
|
+
}
|
|
15
|
+
type ExtractorFunction$0<T = string> = (content: T) => string[];
|
|
16
|
+
interface Extractors$0 {
|
|
17
|
+
extensions: string[];
|
|
18
|
+
extractor: ExtractorFunction$0;
|
|
19
|
+
}
|
|
20
|
+
type OutputFunction = (css: string, styles: string[]) => void;
|
|
21
|
+
interface UserDefinedOptions$0 {
|
|
22
|
+
content: Array<string | RawContent$0>;
|
|
23
|
+
contentFunction?: (sourceFile: string) => Array<string | RawContent$0>;
|
|
24
|
+
defaultExtractor?: ExtractorFunction$0;
|
|
25
|
+
extractors?: Array<Extractors$0>;
|
|
26
|
+
fontFace?: boolean;
|
|
27
|
+
keyframes?: boolean;
|
|
28
|
+
output?: string | OutputFunction | boolean;
|
|
29
|
+
rejected?: boolean;
|
|
30
|
+
stdin?: boolean;
|
|
31
|
+
stdout?: boolean;
|
|
32
|
+
variables?: boolean;
|
|
33
|
+
safelist?: UserDefinedSafelist;
|
|
34
|
+
blocklist?: StringRegExpArray;
|
|
35
|
+
skippedContentGlobs?: Array<string>;
|
|
36
|
+
dynamicAttributes?: string[];
|
|
37
|
+
insert?: boolean;
|
|
38
|
+
include?: string | RegExp | (string | RegExp)[];
|
|
39
|
+
exclude?: string | RegExp | (string | RegExp)[];
|
|
40
|
+
dest?: string;
|
|
41
|
+
}
|
|
42
|
+
declare function pluginPurgeCSS(options: UserDefinedOptions$0): Plugin;
|
|
43
|
+
export { pluginPurgeCSS as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"fs";import{PurgeCSS as e}from"purgecss";import{createFilter as n}from"rollup-pluginutils";function r(r){const u=n(r.include||["**/*.css"],r.exclude||"node_modules/**"),s=[];let o="";return{name:"purgecss",transform:async(t,n)=>{if(!u(n))return null;let o=(await(new e).purge({content:r.content,css:[{raw:t}]}))[0].css;return s.push(o),o=JSON.stringify(o),r.insert||(t=r.output?'"";':o),{code:`export default ${t}`,map:{mappings:""}}},generateBundle(){if(!(r.insert||s.length&&!1!==r.output))return;const e=s.reduce(((t,e)=>t+e),"");return"string"==typeof r.output?t.writeFileSync(r.output,e):"function"==typeof r.output?r.output(e,s):!r.insert&&o?((o.endsWith(".js")||o.endsWith(".ts"))&&(o=o.slice(0,-3)),o=`${o}.css`,t.writeFileSync(o,e)):void 0}}}export{r as default};
|
|
@@ -1,64 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
|
-
|
|
5
|
-
var rollupPluginutils = require('rollup-pluginutils');
|
|
6
|
-
var Purgecss = _interopDefault(require('purgecss'));
|
|
7
|
-
var fs = _interopDefault(require('fs'));
|
|
8
|
-
|
|
9
|
-
const pluginPurgecss = function (options = {}) {
|
|
10
|
-
const filter = rollupPluginutils.createFilter(options.include || ['**/*.css'], options.exclude || 'node_modules/**');
|
|
11
|
-
const styles = [];
|
|
12
|
-
let dest = '';
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
name: 'purgecss',
|
|
16
|
-
transform(code, id) {
|
|
17
|
-
if (!filter(id)) return null;
|
|
18
|
-
|
|
19
|
-
const purgecss = new Purgecss({
|
|
20
|
-
content: options.content,
|
|
21
|
-
css: [{
|
|
22
|
-
raw: code
|
|
23
|
-
}]
|
|
24
|
-
});
|
|
25
|
-
let css = purgecss.purge()[0].css;
|
|
26
|
-
styles.push(css);
|
|
27
|
-
|
|
28
|
-
css = JSON.stringify(css);
|
|
29
|
-
if (options.insert) ; else if (!options.output) {
|
|
30
|
-
code = css;
|
|
31
|
-
} else {
|
|
32
|
-
code = `"";`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
code: `export default ${code}`,
|
|
37
|
-
map: { mappings: '' }
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
ongenerate() {
|
|
41
|
-
if (!options.insert && (!styles.length || options.output === false)) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const css = styles.reduce((acc, value) => {
|
|
45
|
-
return acc + value;
|
|
46
|
-
}, '');
|
|
47
|
-
if (typeof options.output === "string") {
|
|
48
|
-
return fs.writeFileSync(options.output, css);
|
|
49
|
-
}
|
|
50
|
-
if (typeof options.output === "function") {
|
|
51
|
-
return options.output(css, styles);
|
|
52
|
-
}
|
|
53
|
-
if (!options.insert && dest) {
|
|
54
|
-
if (dest.endsWith('.js') || dest.endsWith('.ts')) {
|
|
55
|
-
dest = dest.slice(0, -3);
|
|
56
|
-
}
|
|
57
|
-
dest = `${dest}.css`;
|
|
58
|
-
return fs.writeFileSync(dest, css);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
module.exports = pluginPurgecss;
|
|
1
|
+
"use strict";var e=require("fs"),t=require("purgecss"),u=require("rollup-pluginutils");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e);module.exports=function(e){const r=u.createFilter(e.include||["**/*.css"],e.exclude||"node_modules/**"),s=[];let i="";return{name:"purgecss",transform:async(u,n)=>{if(!r(n))return null;let i=(await(new t.PurgeCSS).purge({content:e.content,css:[{raw:u}]}))[0].css;return s.push(i),i=JSON.stringify(i),e.insert||(u=e.output?'"";':i),{code:`export default ${u}`,map:{mappings:""}}},generateBundle(){if(!(e.insert||s.length&&!1!==e.output))return;const t=s.reduce(((e,t)=>e+t),"");return"string"==typeof e.output?n.default.writeFileSync(e.output,t):"function"==typeof e.output?e.output(t,s):!e.insert&&i?((i.endsWith(".js")||i.endsWith(".ts"))&&(i=i.slice(0,-3)),i=`${i}.css`,n.default.writeFileSync(i,t)):void 0}}};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup-plugin-purgecss",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Rollup plugin for purgecss",
|
|
5
5
|
"main": "lib/rollup-plugin-purgecss.js",
|
|
6
6
|
"module": "./lib/rollup-plugin-purgecss.es.js",
|
|
@@ -10,13 +10,11 @@
|
|
|
10
10
|
"test": "__tests__"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"
|
|
14
|
-
"test": "npx ava __tests__/index.test.js -s",
|
|
15
|
-
"lint": "npx eslint -c .eslintrc src/"
|
|
13
|
+
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
16
14
|
},
|
|
17
15
|
"repository": {
|
|
18
16
|
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/FullHuman/
|
|
17
|
+
"url": "git+https://github.com/FullHuman/purgecss.git"
|
|
20
18
|
},
|
|
21
19
|
"keywords": [
|
|
22
20
|
"rollup-plugin",
|
|
@@ -28,22 +26,16 @@
|
|
|
28
26
|
"author": "Ffloriel",
|
|
29
27
|
"license": "MIT",
|
|
30
28
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/FullHuman/
|
|
32
|
-
},
|
|
33
|
-
"homepage": "https://github.com/FullHuman/rollup-plugin-purgecss#readme",
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"ava": "^0.25.0",
|
|
36
|
-
"babel-plugin-external-helpers": "^6.22.0",
|
|
37
|
-
"babel-preset-env": "^1.7.0",
|
|
38
|
-
"eslint": "^4.19.1",
|
|
39
|
-
"jest": "^22.4.4",
|
|
40
|
-
"rollup": "^0.59.2",
|
|
41
|
-
"rollup-plugin-babel": "^3.0.4",
|
|
42
|
-
"rollup-plugin-commonjs": "^9.1.3",
|
|
43
|
-
"rollup-plugin-node-resolve": "^3.3.0"
|
|
29
|
+
"url": "https://github.com/FullHuman/purgecss/issues"
|
|
44
30
|
},
|
|
31
|
+
"homepage": "https://purgecss.com",
|
|
45
32
|
"dependencies": {
|
|
46
|
-
"purgecss": "^1.
|
|
47
|
-
"rollup-pluginutils": "^2.
|
|
48
|
-
}
|
|
33
|
+
"purgecss": "^4.1.1",
|
|
34
|
+
"rollup-pluginutils": "^2.8.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"registry": "https://registry.npmjs.org/"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "e87bc559054526ab99db05de8a455bdfc0858101"
|
|
49
41
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { PurgeCSS } from "purgecss";
|
|
3
|
+
import { Plugin } from "rollup";
|
|
4
|
+
import { createFilter } from "rollup-pluginutils";
|
|
5
|
+
import { UserDefinedOptions } from "./types";
|
|
6
|
+
|
|
7
|
+
function pluginPurgeCSS(options: UserDefinedOptions): Plugin {
|
|
8
|
+
const filter = createFilter(
|
|
9
|
+
options.include || ["**/*.css"],
|
|
10
|
+
options.exclude || "node_modules/**"
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const styles: string[] = [];
|
|
14
|
+
let dest = "";
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
name: "purgecss",
|
|
18
|
+
transform: async (code, id) => {
|
|
19
|
+
if (!filter(id)) return null;
|
|
20
|
+
|
|
21
|
+
const v = await new PurgeCSS().purge({
|
|
22
|
+
content: options.content,
|
|
23
|
+
css: [
|
|
24
|
+
{
|
|
25
|
+
raw: code,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
});
|
|
29
|
+
let css = v[0].css;
|
|
30
|
+
|
|
31
|
+
styles.push(css);
|
|
32
|
+
|
|
33
|
+
css = JSON.stringify(css);
|
|
34
|
+
if (options.insert) {
|
|
35
|
+
// do thing
|
|
36
|
+
} else if (!options.output) {
|
|
37
|
+
code = css;
|
|
38
|
+
} else {
|
|
39
|
+
code = `"";`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
code: `export default ${code}`,
|
|
44
|
+
map: { mappings: "" },
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
generateBundle() {
|
|
48
|
+
if (!options.insert && (!styles.length || options.output === false)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const css = styles.reduce((acc, value) => {
|
|
52
|
+
return acc + value;
|
|
53
|
+
}, "");
|
|
54
|
+
if (typeof options.output === "string") {
|
|
55
|
+
return fs.writeFileSync(options.output, css);
|
|
56
|
+
}
|
|
57
|
+
if (typeof options.output === "function") {
|
|
58
|
+
return options.output(css, styles);
|
|
59
|
+
}
|
|
60
|
+
if (!options.insert && dest) {
|
|
61
|
+
if (dest.endsWith(".js") || dest.endsWith(".ts")) {
|
|
62
|
+
dest = dest.slice(0, -3);
|
|
63
|
+
}
|
|
64
|
+
dest = `${dest}.css`;
|
|
65
|
+
return fs.writeFileSync(dest, css);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default pluginPurgeCSS;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StringRegExpArray,
|
|
3
|
+
UserDefinedSafelist,
|
|
4
|
+
} from "../../../purgecss/src/types/index";
|
|
5
|
+
|
|
6
|
+
export interface RawContent<T = string> {
|
|
7
|
+
extension: string;
|
|
8
|
+
raw: T;
|
|
9
|
+
}
|
|
10
|
+
export interface RawCSS {
|
|
11
|
+
raw: string;
|
|
12
|
+
}
|
|
13
|
+
type ExtractorFunction<T = string> = (content: T) => string[];
|
|
14
|
+
export interface Extractors {
|
|
15
|
+
extensions: string[];
|
|
16
|
+
extractor: ExtractorFunction;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type OutputFunction = (css: string, styles: string[]) => void;
|
|
20
|
+
|
|
21
|
+
export interface UserDefinedOptions {
|
|
22
|
+
content: Array<string | RawContent>;
|
|
23
|
+
contentFunction?: (sourceFile: string) => Array<string | RawContent>;
|
|
24
|
+
defaultExtractor?: ExtractorFunction;
|
|
25
|
+
extractors?: Array<Extractors>;
|
|
26
|
+
fontFace?: boolean;
|
|
27
|
+
keyframes?: boolean;
|
|
28
|
+
output?: string | OutputFunction | boolean;
|
|
29
|
+
rejected?: boolean;
|
|
30
|
+
stdin?: boolean;
|
|
31
|
+
stdout?: boolean;
|
|
32
|
+
variables?: boolean;
|
|
33
|
+
safelist?: UserDefinedSafelist;
|
|
34
|
+
blocklist?: StringRegExpArray;
|
|
35
|
+
skippedContentGlobs?: Array<string>;
|
|
36
|
+
dynamicAttributes?: string[];
|
|
37
|
+
|
|
38
|
+
insert?: boolean;
|
|
39
|
+
include?: string | RegExp | (string | RegExp)[];
|
|
40
|
+
exclude?: string | RegExp | (string | RegExp)[];
|
|
41
|
+
dest?: string;
|
|
42
|
+
}
|
package/.circleci/config.yml
DELETED
package/.eslintrc
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
-
|
|
7
|
-
## Our Standards
|
|
8
|
-
|
|
9
|
-
Examples of behavior that contributes to creating a positive environment include:
|
|
10
|
-
|
|
11
|
-
* Using welcoming and inclusive language
|
|
12
|
-
* Being respectful of differing viewpoints and experiences
|
|
13
|
-
* Gracefully accepting constructive criticism
|
|
14
|
-
* Focusing on what is best for the community
|
|
15
|
-
* Showing empathy towards other community members
|
|
16
|
-
|
|
17
|
-
Examples of unacceptable behavior by participants include:
|
|
18
|
-
|
|
19
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
20
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
-
* Public or private harassment
|
|
22
|
-
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
23
|
-
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
-
|
|
25
|
-
## Our Responsibilities
|
|
26
|
-
|
|
27
|
-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
28
|
-
|
|
29
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
-
|
|
31
|
-
## Scope
|
|
32
|
-
|
|
33
|
-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
34
|
-
|
|
35
|
-
## Enforcement
|
|
36
|
-
|
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at florielfedry@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
38
|
-
|
|
39
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
40
|
-
|
|
41
|
-
## Attribution
|
|
42
|
-
|
|
43
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
|
44
|
-
|
|
45
|
-
[homepage]: http://contributor-covenant.org
|
|
46
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Before you open an issue, please check if a similar issue already exists or has been closed before.
|
|
2
|
-
|
|
3
|
-
### When reporting a bug, please be sure to include the following:
|
|
4
|
-
- [ ] A descriptive title
|
|
5
|
-
- [ ] An *isolated* way to reproduce the behavior (example: GitHub repository with code isolated to the issue that anyone can clone to observe the problem)
|
|
6
|
-
- [ ] What version of `rollup-plugin-purgecss` you're using, and the platform(s) you're running it on
|
|
7
|
-
- [ ] The behavior you expect to see, and the actual behavior
|
|
8
|
-
|
|
9
|
-
### When you open an issue for a feature request, please add as much detail as possible:
|
|
10
|
-
- [ ] A descriptive title
|
|
11
|
-
- [ ] A description of the problem you're trying to solve, including *why* you think this is a problem
|
|
12
|
-
- [ ] An overview of the suggested solution
|
|
13
|
-
- [ ] If the feature changes current behavior, reasons why your solution is better
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
## Proposed changes
|
|
2
|
-
|
|
3
|
-
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
|
|
4
|
-
|
|
5
|
-
## Types of changes
|
|
6
|
-
|
|
7
|
-
What types of changes does your code introduce to rollup-plugin-purgecss?
|
|
8
|
-
_Put an `x` in the boxes that apply_
|
|
9
|
-
|
|
10
|
-
- [ ] Bugfix (non-breaking change which fixes an issue)
|
|
11
|
-
- [ ] New feature (non-breaking change which adds functionality)
|
|
12
|
-
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
|
13
|
-
|
|
14
|
-
## Checklist
|
|
15
|
-
|
|
16
|
-
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
|
|
17
|
-
|
|
18
|
-
- [ ] Lint and unit tests pass locally with my changes
|
|
19
|
-
- [ ] I have added tests that prove my fix is effective or that my feature works
|
|
20
|
-
- [ ] I have added necessary documentation (if appropriate)
|
|
21
|
-
|
|
22
|
-
## Further comments
|
|
23
|
-
|
|
24
|
-
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...
|
package/.travis.yml
DELETED
package/CONTRIBUTING.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
## [Code of Conduct](./.github/CODE_OF_CONDUCT.md)
|
|
3
|
-
|
|
4
|
-
FullHuman has adopted the Contributor Covenant Code of Conduct for all of its project.
|
|
5
|
-
Please read the text so that you understand how to conduct while contributing to this project.
|
|
6
|
-
|
|
7
|
-
## Semantic Versioning
|
|
8
|
-
|
|
9
|
-
Purgecss use [SemVer](http://semver.org/) for versioning.
|
|
10
|
-
|
|
11
|
-
## Sending a Pull Request
|
|
12
|
-
|
|
13
|
-
**Before submitting a pull request,** please make sure the following is done:
|
|
14
|
-
|
|
15
|
-
1. Fork [the repository](https://github.com/FullHuman/rollup-plugin-purgecss) and create your branch from `master`.
|
|
16
|
-
2. If you've added code that should be tested, add tests!
|
|
17
|
-
3. If you've changed APIs, update the documentation.
|
|
18
|
-
4. Ensure the test suite passes (`npm test`).
|
|
19
|
-
5. Make sure your code lints (`npm run lint`).
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### Development Workflow
|
|
23
|
-
|
|
24
|
-
After cloning Purgecss, run `npm i` to fetch its dependencies.
|
|
25
|
-
Then, you can run several commands:
|
|
26
|
-
|
|
27
|
-
- `npm run dev` will build cjs and es module of Purgecss in the `lib` folder and watch for changes.
|
|
28
|
-
- `npm run lint` checks the code style.
|
|
29
|
-
- `npm test` runs the complete test suite.
|
|
30
|
-
- `npm test -- --watch` runs an interactive test watcher.
|
|
31
|
-
- `npm test <pattern>` runs tests with matching filenames.
|
|
32
|
-
- `npm run build` creates the cjs and es module of Purgecss in the `lib` folder.
|
|
33
|
-
|
|
34
|
-
Make sure that your pull request contains unit tests for any new functionality. This way we can ensure that we don't break your code in the future.
|
|
35
|
-
|
|
36
|
-
### License
|
|
37
|
-
|
|
38
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
39
|
-
|
|
40
|
-
### Aknowledgement
|
|
41
|
-
|
|
42
|
-
This CONTRIBUTING.md is based on the [react](https://github.com/facebook/react) [how-to-contribute.md](https://github.com/facebook/react/blob/master/docs/contributing/how-to-contribute.md) file.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.used{color: blue;}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.unused,a{color: green;}
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
body{color:green}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
body{color:blue}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
body{color:red;background-color:green}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
body{color:red}
|
package/__tests__/index.test.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import test from 'ava'
|
|
3
|
-
import { rollup } from 'rollup'
|
|
4
|
-
import purgecss from "../lib/rollup-plugin-purgecss"
|
|
5
|
-
import babel from 'rollup-plugin-babel'
|
|
6
|
-
|
|
7
|
-
const expectA = fs.readFileSync('__tests__/assets/expect_a.css').toString()
|
|
8
|
-
const expectB = fs.readFileSync('__tests__/assets/expect_b.css').toString()
|
|
9
|
-
const expectC = fs.readFileSync('__tests__/assets/expect_c.css').toString()
|
|
10
|
-
const expectD = fs.readFileSync('__tests__/assets/expect_d.css').toString()
|
|
11
|
-
const expectE = fs.readFileSync('__tests__/assets/expect_e.css').toString()
|
|
12
|
-
|
|
13
|
-
const squash = str => str.trim().replace(/\r/g, '')
|
|
14
|
-
|
|
15
|
-
test('should import *.css files', t => {
|
|
16
|
-
return rollup({
|
|
17
|
-
input: '__tests__/fixtures/basic/index.js',
|
|
18
|
-
plugins: [
|
|
19
|
-
purgecss({
|
|
20
|
-
content: ["__tests__/assets/test_a.html"]
|
|
21
|
-
})
|
|
22
|
-
]
|
|
23
|
-
}).then(bundle => {
|
|
24
|
-
return bundle.generate({format: "cjs"})
|
|
25
|
-
.then(value => {
|
|
26
|
-
const result = value.code
|
|
27
|
-
t.true(result.includes(squash(expectA)))
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
})
|
|
31
|
-
})
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createFilter } from 'rollup-pluginutils';
|
|
2
|
-
import Purgecss from 'purgecss';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
|
|
5
|
-
const pluginPurgecss = function (options = {}) {
|
|
6
|
-
const filter = createFilter(options.include || ['**/*.css'], options.exclude || 'node_modules/**');
|
|
7
|
-
const styles = [];
|
|
8
|
-
let dest = '';
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
name: 'purgecss',
|
|
12
|
-
transform(code, id) {
|
|
13
|
-
if (!filter(id)) return null;
|
|
14
|
-
|
|
15
|
-
const purgecss = new Purgecss({
|
|
16
|
-
content: options.content,
|
|
17
|
-
css: [{
|
|
18
|
-
raw: code
|
|
19
|
-
}]
|
|
20
|
-
});
|
|
21
|
-
let css = purgecss.purge()[0].css;
|
|
22
|
-
styles.push(css);
|
|
23
|
-
|
|
24
|
-
css = JSON.stringify(css);
|
|
25
|
-
if (options.insert) ; else if (!options.output) {
|
|
26
|
-
code = css;
|
|
27
|
-
} else {
|
|
28
|
-
code = `"";`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
code: `export default ${code}`,
|
|
33
|
-
map: { mappings: '' }
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
ongenerate() {
|
|
37
|
-
if (!options.insert && (!styles.length || options.output === false)) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const css = styles.reduce((acc, value) => {
|
|
41
|
-
return acc + value;
|
|
42
|
-
}, '');
|
|
43
|
-
if (typeof options.output === "string") {
|
|
44
|
-
return fs.writeFileSync(options.output, css);
|
|
45
|
-
}
|
|
46
|
-
if (typeof options.output === "function") {
|
|
47
|
-
return options.output(css, styles);
|
|
48
|
-
}
|
|
49
|
-
if (!options.insert && dest) {
|
|
50
|
-
if (dest.endsWith('.js') || dest.endsWith('.ts')) {
|
|
51
|
-
dest = dest.slice(0, -3);
|
|
52
|
-
}
|
|
53
|
-
dest = `${dest}.css`;
|
|
54
|
-
return fs.writeFileSync(dest, css);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default pluginPurgecss;
|
package/rollup.config.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import babel from "rollup-plugin-babel"
|
|
2
|
-
import commonjs from "rollup-plugin-commonjs"
|
|
3
|
-
import resolve from "rollup-plugin-node-resolve"
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
input: "./src/index.js",
|
|
7
|
-
output: [
|
|
8
|
-
{
|
|
9
|
-
file: "./lib/rollup-plugin-purgecss.es.js",
|
|
10
|
-
format: "es"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
file: "./lib/rollup-plugin-purgecss.js",
|
|
14
|
-
format: "cjs"
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
plugins: [
|
|
18
|
-
resolve(), commonjs(), babel()
|
|
19
|
-
],
|
|
20
|
-
external: [
|
|
21
|
-
"purgecss",
|
|
22
|
-
"rollup-pluginutils",
|
|
23
|
-
"fs"
|
|
24
|
-
]
|
|
25
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { createFilter } from 'rollup-pluginutils'
|
|
2
|
-
import Purgecss from "purgecss"
|
|
3
|
-
import fs from "fs"
|
|
4
|
-
|
|
5
|
-
const pluginPurgecss = function( options = {} ) {
|
|
6
|
-
const filter = createFilter( options.include || ['**/*.css'], options.exclude || 'node_modules/**')
|
|
7
|
-
const styles = []
|
|
8
|
-
let dest = ''
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
name: 'purgecss',
|
|
12
|
-
transform(code, id) {
|
|
13
|
-
if (!filter(id)) return null
|
|
14
|
-
|
|
15
|
-
const purgecss = new Purgecss({
|
|
16
|
-
content: options.content,
|
|
17
|
-
css: [{
|
|
18
|
-
raw: code
|
|
19
|
-
}]
|
|
20
|
-
})
|
|
21
|
-
let css = purgecss.purge()[0].css
|
|
22
|
-
styles.push(css)
|
|
23
|
-
|
|
24
|
-
css = JSON.stringify(css)
|
|
25
|
-
if (options.insert) {
|
|
26
|
-
// do thing
|
|
27
|
-
} else if (!options.output) {
|
|
28
|
-
code = css
|
|
29
|
-
} else {
|
|
30
|
-
code = `"";`
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
code:`export default ${code}`,
|
|
35
|
-
map: { mappings: '' }
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
ongenerate() {
|
|
39
|
-
if (!options.insert && (!styles.length || options.output === false)) {
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
const css = styles.reduce((acc, value) => {
|
|
43
|
-
return acc + value
|
|
44
|
-
}, '')
|
|
45
|
-
if (typeof options.output === "string") {
|
|
46
|
-
return fs.writeFileSync(options.output, css)
|
|
47
|
-
}
|
|
48
|
-
if (typeof options.output === "function") {
|
|
49
|
-
return options.output(css, styles)
|
|
50
|
-
}
|
|
51
|
-
if (!options.insert && dest) {
|
|
52
|
-
if (dest.endsWith('.js') || dest.endsWith('.ts')) {
|
|
53
|
-
dest = dest.slice(0, -3)
|
|
54
|
-
}
|
|
55
|
-
dest = `${dest}.css`
|
|
56
|
-
return fs.writeFileSync(dest, css)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default pluginPurgecss
|