Created
February 5, 2019 00:11
-
-
Save rodurma/1d3714c908fa7bff617d0f953e7cb8aa to your computer and use it in GitHub Desktop.
Tailwind.js
This file contains hidden or 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
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