Skip to content

Instantly share code, notes, and snippets.

@PhouvanhKCSV
Forked from reinink/webpack.mix.js
Created December 6, 2017 02:10
Show Gist options
  • Save PhouvanhKCSV/778f2af4727c2084aed9b327783193be to your computer and use it in GitHub Desktop.
Save PhouvanhKCSV/778f2af4727c2084aed9b327783193be to your computer and use it in GitHub Desktop.
Using Purgecss with Tailwind and Laravel Mix
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