Skip to content

Commit daf9a20

Browse files
committed
Make that css smol
1 parent aea6944 commit daf9a20

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

webpack.config.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
const path = require('path');
2+
const tailwind = require('tailwindcss');
3+
const glob = require('glob-all');
4+
25
const AssetsManifestPlugin = require('webpack-assets-manifest');
36
const CleanPlugin = require('clean-webpack-plugin');
47
const ExtractTextPlugin = require('extract-text-webpack-plugin');
58
const ShellPlugin = require('webpack-shell-plugin');
69
const MinifyPlugin = require('babel-minify-webpack-plugin');
10+
const PurgeCssPlugin = require('purgecss-webpack-plugin');
11+
12+
// Custom PurgeCSS extractor for Tailwind that allows special characters in
13+
// class names.
14+
//
15+
// https://github.com/FullHuman/purgecss#extractor
16+
class TailwindExtractor {
17+
static extract(content) {
18+
return content.match(/[A-z0-9-:\/]+/g) || [];
19+
}
20+
}
721

822
module.exports = {
923
mode: 'development',
@@ -28,7 +42,7 @@ module.exports = {
2842
postcss: [
2943
require('postcss-import'),
3044
require('postcss-preset-env')({stage: 0}),
31-
require('tailwindcss')('./tailwind.js'),
45+
tailwind('./tailwind.js'),
3246
require('autoprefixer'),
3347
]
3448
}
@@ -49,7 +63,10 @@ module.exports = {
4963
fallback: 'style-loader',
5064
use: [{
5165
loader: 'css-loader',
52-
options: {importLoaders: 1},
66+
options: {
67+
importLoaders: 1,
68+
minimize: true,
69+
},
5370
}, {
5471
loader: 'postcss-loader',
5572
options: {
@@ -73,6 +90,18 @@ module.exports = {
7390
extensions: ['*', '.js', '.vue', '.json']
7491
},
7592
plugins: [
93+
new PurgeCssPlugin({
94+
paths: glob.sync([
95+
path.join(__dirname, 'resources/assets/scripts/**/*.vue'),
96+
path.join(__dirname, 'resources/themes/pterodactyl/**/*.blade.php'),
97+
]),
98+
extractors: [
99+
{
100+
extractor: TailwindExtractor,
101+
extensions: ['html', 'js', 'php', 'vue'],
102+
}
103+
],
104+
}),
76105
new CleanPlugin(path.resolve(__dirname, 'public/assets')),
77106
new ShellPlugin({
78107
onBuildStart: [

0 commit comments

Comments
 (0)