Skip to content

Instantly share code, notes, and snippets.

@mahansky
Last active July 10, 2018 18:34
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 mahansky/2e8087afefeb325d19a1f069d4abbb2f to your computer and use it in GitHub Desktop.
Save mahansky/2e8087afefeb325d19a1f069d4abbb2f to your computer and use it in GitHub Desktop.

Dependencies

yarn add laravel-mix laravel-mix-purgecss cross-env tailwindcss postcss-import postcss-nesting

Installation

cp -r node_modules/laravel-mix/setup/webpack.mix.js ./
node_modules/.bin/tailwind init

package.json scripts

"scripts": {
  "dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
  "prod": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
  "watch": "npm run dev -- --watch",
}

webpack.mix.js

let mix = require('laravel-mix')
require('laravel-mix-purgecss')

mix
    .postCss('src/css/app.css', 'public/css')
    .options({
        postCss: [
            require('postcss-import')(),
            require('tailwindcss')('./tailwind.js'),
            require('postcss-nesting')(),
        ]
    })
    .purgeCss()

Tailwindcss imports

@tailwind preflight;
@tailwind components;
@tailwind utilities;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment