|
1 | 1 | let mix = require('laravel-mix');
|
2 |
| -var tailwindcss = require('tailwindcss'); |
| 2 | +let 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-z0-9-:\/]+/g) || []; |
| 9 | + } |
| 10 | +} |
3 | 11 |
|
4 | 12 | /*
|
5 | 13 | |--------------------------------------------------------------------------
|
@@ -31,3 +39,33 @@ mix.js('resources/assets/js/app.js', 'public/js')
|
31 | 39 | // processCssUrls: false,
|
32 | 40 | // postCss: [ tailwindcss('tailwind.js') ],
|
33 | 41 | // });
|
| 42 | + |
| 43 | +// PurgeCSS is a utility that parses your application view files, identifies which |
| 44 | +// utility classes are actually being used, removing unused classes. This means |
| 45 | +// your final CSS will be much smaller, containing just the styles you need. |
| 46 | +// |
| 47 | +// Only run PurgeCSS in production builds keeping your development builds fast, |
| 48 | +// whilst still leaving you with a full set of utilities during development. |
| 49 | +// if (mix.inProduction()) { |
| 50 | +// mix.webpackConfig({ |
| 51 | +// plugins: [ |
| 52 | +// new PurgecssPlugin({ |
| 53 | +// |
| 54 | +// // Specify the locations of any files you want to scan for class names. |
| 55 | +// paths: glob.sync([ |
| 56 | +// path.join(__dirname, "resources/views/**/*.blade.php"), |
| 57 | +// path.join(__dirname, "resources/assets/js/**/*.vue") |
| 58 | +// ]), |
| 59 | +// extractors: [ |
| 60 | +// { |
| 61 | +// extractor: TailwindExtractor, |
| 62 | +// |
| 63 | +// // Specify the file extensions to include when scanning for class names. |
| 64 | +// extensions: ["html", "js", "php", "vue"] |
| 65 | +// } |
| 66 | +// ] |
| 67 | +// }) |
| 68 | +// ] |
| 69 | +// }); |
| 70 | +// } |
| 71 | + |
0 commit comments