File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1
1
let mix = require ( 'laravel-mix' ) ;
2
2
var tailwindcss = require ( 'tailwindcss' ) ;
3
+ let glob = require ( "glob-all" ) ;
4
+ let PurgecssPlugin = require ( "purgecss-webpack-plugin" ) ;
5
+
6
+ class TailwindExtractor {
7
+ static extract ( content ) {
8
+ return content . match ( / [ A - z 0 - 9 -:\/ ] + / g) || [ ] ;
9
+ }
10
+ }
3
11
4
12
/*
5
13
|--------------------------------------------------------------------------
@@ -31,3 +39,31 @@ mix.js('resources/assets/js/app.js', 'public/js')
31
39
// processCssUrls: false,
32
40
// postCss: [ tailwindcss('tailwind.js') ],
33
41
// });
42
+
43
+ // Only run PurgeCSS during production builds for faster development builds
44
+ // and so you still have the full set of utilities available during
45
+ // development.
46
+ if ( mix . inProduction ( ) ) {
47
+ mix . webpackConfig ( {
48
+ plugins : [
49
+ new PurgecssPlugin ( {
50
+
51
+ // Specify the locations of any files you want to scan for class names.
52
+ paths : glob . sync ( [
53
+ path . join ( __dirname , "resources/views/**/*.blade.php" ) ,
54
+ path . join ( __dirname , "resources/assets/js/**/*.vue" )
55
+ ] ) ,
56
+ extractors : [
57
+ {
58
+ extractor : TailwindExtractor ,
59
+
60
+ // Specify the file extensions to include when scanning for
61
+ // class names.
62
+ extensions : [ "html" , "js" , "php" , "vue" ]
63
+ }
64
+ ]
65
+ } )
66
+ ]
67
+ } ) ;
68
+ }
69
+
You can’t perform that action at this time.
0 commit comments