11const path = require ( 'path' ) ;
2+ const tailwind = require ( 'tailwindcss' ) ;
3+ const glob = require ( 'glob-all' ) ;
4+
25const AssetsManifestPlugin = require ( 'webpack-assets-manifest' ) ;
36const CleanPlugin = require ( 'clean-webpack-plugin' ) ;
47const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
58const ShellPlugin = require ( 'webpack-shell-plugin' ) ;
69const 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 - z 0 - 9 -:\/ ] + / g) || [ ] ;
19+ }
20+ }
721
822module . 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