Skip to content
This repository was archived by the owner on Feb 1, 2020. It is now read-only.

Commit 0829f9d

Browse files
committed
update example
- update example with custom extractor
1 parent 5cfe7ed commit 0829f9d

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

examples/simple/dist/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function component() {
8484
element.innerHTML = __WEBPACK_IMPORTED_MODULE_0_lodash___default.a.join(['Hello', 'webpack'], ' ')
8585
element.classList.add('hello')
8686
element.classList.add('whitelisted')
87+
element.classList.add('md:w-2/3')
8788
return element
8889
}
8990

examples/simple/dist/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
.whitelisted {
66
color: green;
77
}
8+
9+
md\:w-2\/3 {
10+
color: red;
11+
}

examples/simple/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function component() {
99
element.innerHTML = _.join(['Hello', 'webpack'], ' ')
1010
element.classList.add('hello')
1111
element.classList.add('whitelisted')
12+
element.classList.add('md:w-2/3')
1213
return element
1314
}
1415

examples/simple/src/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
.whitelisted {
1010
color: green;
1111
}
12+
13+
md\:w-2\/3 {
14+
color: red;
15+
}

examples/simple/webpack.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ const glob = require('glob')
33
const ExtractTextPlugin = require('extract-text-webpack-plugin')
44
const PurgecssPlugin = require('../../')
55

6+
class CustomExtractor {
7+
static extract(content) {
8+
return content.match(/[A-z0-9-:/]+/g)
9+
}
10+
}
11+
612
const PATHS = {
713
src: path.join(__dirname, 'src')
814
}
@@ -29,7 +35,13 @@ module.exports = {
2935
new PurgecssPlugin({
3036
paths: glob.sync(`${PATHS.src}/*`),
3137
styleExtensions: ['.css'],
32-
whitelist: ['whitelisted']
38+
whitelist: ['whitelisted'],
39+
extractors: [
40+
{
41+
extractor: CustomExtractor,
42+
extensions: ['html', 'js']
43+
}
44+
]
3345
})
3446
]
3547
}

0 commit comments

Comments
 (0)