Skip to content

Instantly share code, notes, and snippets.

@denjaland
Created April 3, 2020 13:14
Show Gist options
  • Save denjaland/3d78b96807492a7fd2b7c5ff43f9b3f2 to your computer and use it in GitHub Desktop.
Save denjaland/3d78b96807492a7fd2b7c5ff43f9b3f2 to your computer and use it in GitHub Desktop.
laravel mix
let mix = require('laravel-mix');
let tailwindcss = require('tailwindcss');
let atImport = require('postcss-import');
let glob = require("glob-all");
let PurgecssPlugin = require("purgecss-webpack-plugin");
const TailwindExtractor = (content) => {
return content.match(/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g) || [];
}
mix.js('resources/js/kribbel.js', 'public/js')
.js('resources/js/daycare.js', 'public/js')
.extract(['vue', 'vuex', 'laravel-echo', 'moment', 'pusher-js', 'vue-i18n', 'vue-router'])
.postCss('resources/tailwind/kribbel.css', 'public/css', [
atImport(),
tailwindcss('resources/tailwind/kribbel.tailwind.config.js'),
])
.postCss('resources/tailwind/daycare.css', 'public/css', [
atImport(),
tailwindcss('resources/tailwind/daycare.tailwind.config.js'),
])
.minify('public/css/kribbel.css')
.minify('public/css/daycare.css')
.minify('public/js/kribbel.js')
.minify('public/js/daycare.js')
.minify('public/js/vendor.js')
.minify('public/js/manifest.js')
.sourceMaps()
.copy('resources/img', 'public/img')
.version([]);
.webpackConfig({
plugins: [
new PurgecssPlugin({
paths: glob.sync([
path.join(__dirname, "resources/views/**/*.blade.php"),
path.join(__dirname, "resources/js/**/*.vue"),
]),
extractors: [
{
extractor: TailwindExtractor,
extensions: ["html", "js", "php", "vue"]
}
]
}),
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment