Skip to content

Instantly share code, notes, and snippets.

@philipboomy
Last active October 25, 2019 17:17
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save philipboomy/b4f22c26cca62f0779714ac97ebe7cb2 to your computer and use it in GitHub Desktop.
Laravel Mix 4 with Tailwind and Purge
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
require('laravel-mix-purgecss');
mix.setPublicPath('./web')
.postCss('src/css/main.css', 'css')
.options({
postCss: [tailwindcss('tailwind.config.js'), require('autoprefixer')],
processCssUrls: false,
})
.js([
'src/js/main.js',
], 'js')
.browserSync({
proxy: 'http://example.test',
browser: 'firefox',
files: ['templates/*.twig','templates/**/*.twig','web/css/*.css','web/js/*.js']
});
mix.disableSuccessNotifications();
if (mix.inProduction()) {
mix.purgeCss({
enabled: true,
globs: [
path.join(__dirname, 'templates/*.twig'),
path.join(__dirname, 'templates/**/*.twig'),
path.join(__dirname, 'templates/**/**/*.twig'),
path.join(__dirname, 'src/js/*.js'),
],
extensions: ['html', 'js', 'twig', 'vue'],
whitelist: [
],
folders: ['src', 'templates'],
})
.version();
};
@jdsimcoe
Copy link

Hey @philipboomy I see that you are using .version() to version assets in production. How are you passing them into your Twig templates in Craft CMS?

@philipboomy
Copy link
Author

I am using Twigpack https://plugins.craftcms.com/twigpack

Let me know if you can't get it to work.

@jdsimcoe
Copy link

jdsimcoe commented Oct 22, 2019

Wow, this is cool! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment