Skip to content

Instantly share code, notes, and snippets.

@philipboomy
Forked from julienbourdeau/webpack.mix.js
Created April 20, 2020 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipboomy/e67371f142203c31faf40a6688c33262 to your computer and use it in GitHub Desktop.
Save philipboomy/e67371f142203c31faf40a6688c33262 to your computer and use it in GitHub Desktop.
Laravel Mix with multiple Tailwind config and PurgeCSS (separate Admin dashboard and Front app)
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
const rootPath = Mix.paths.root.bind(Mix.paths);
const tailwindPlugins = function(configFile, paths) {
const pluginList = [tailwindcss(configFile)];
if (mix.inProduction()) {
pluginList.push(require('@fullhuman/postcss-purgecss')({
content: paths.map((path) => rootPath(path)),
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || [],
whitelistPatterns: [/-active$/, /-enter$/, /-leave-to$/]
}))
}
return pluginList;
}
mix
.js('resources/js/front/front.js', 'public/js/')
.sass(
'resources/css/front.scss',
'public/css/',
{},
tailwindPlugins(
'resources/css/tailwind.front.config.js',
[
'resources/views/front/**/*.html',
'resources/views/front/**/*.php',
'resources/js/front/**/*.vue',
]
)
)
.sass(
'resources/css/admin.scss',
'public/css/admin/',
{},
tailwindPlugins(
'resources/css/tailwind.admin.config.js',
[
'resources/views/components/admin/**/*.php',
'resources/views/admin/**/*.html',
'resources/views/admin/**/*.php',
'resources/views/auth/**/*.html',
'resources/views/auth/**/*.php',
'resources/js/admin/**/*.vue',
]
)
)
.options({
processCssUrls: false,
})
.browserSync('boucherie.test');
if (mix.inProduction()) {
mix.version();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment