-
-
Save vesper8/6080433efb600b00f156a3a3e55287c0 to your computer and use it in GitHub Desktop.
Using Purgecss with Tailwind and Laravel Mix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cssImport = require('postcss-import') | |
let cssNext = require('postcss-cssnext') | |
let glob = require('glob-all') | |
let mix = require('laravel-mix') | |
let purgeCss = require('purgecss-webpack-plugin') | |
let tailwind = require('tailwindcss') | |
mix.js('resources/assets/js/app.js', 'public/js') | |
.postCss('resources/assets/css/app.css', 'public/css/app.css', [ | |
cssImport(), | |
tailwind('tailwind.js'), | |
cssNext({ features: { autoprefixer: false }}), | |
]) | |
.version() | |
if (mix.inProduction()) { | |
mix.webpackConfig({ | |
plugins: [ | |
new purgeCss({ | |
paths: glob.sync([ | |
path.join(__dirname, 'resources/views/**/*.blade.php'), | |
path.join(__dirname, 'resources/assets/js/**/*.vue') | |
]), | |
extractors: [ | |
{ | |
extractor: class { | |
static extract(content) { | |
return content.match(/[A-z0-9-:\/]+/g) | |
} | |
}, | |
extensions: ['html', 'js', 'php', 'vue'] | |
} | |
] | |
}) | |
] | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment