Skip to content

Instantly share code, notes, and snippets.

@rodurma
Created February 5, 2019 00:11
Show Gist options
  • Save rodurma/1d3714c908fa7bff617d0f953e7cb8aa to your computer and use it in GitHub Desktop.
Save rodurma/1d3714c908fa7bff617d0f953e7cb8aa to your computer and use it in GitHub Desktop.
Tailwind.js
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
const glob = require("glob-all");
const PurgecssPlugin = require("purgecss-webpack-plugin");
class TailwindExtractor {
static extract(content) {
return content.match(/[A-Za-z0-9-_:\/]+/g) || [];
}
}
mix.sass('resources/sass/app.scss', 'public/css')
.options({
processCssUrls: false,
postCss: [ tailwindcss('./tailwind.js') ],
}
);
if (mix.inProduction()) {
mix.webpackConfig({
plugins: [
new PurgecssPlugin({
// Specify the locations of any files you want to scan for class names.
paths: glob.sync([
path.join(__dirname, "resources/views/**/*.blade.php"),
path.join(__dirname, "resources/js/**/*.vue")
]),
extractors: [
{
extractor: TailwindExtractor,
// Specify the file extensions to include when scanning for
// class names.
extensions: ["html", "js", "php", "vue"]
}
]
})
]
});
}
mix.disableNotifications();
mix.version();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment