Skip to content

Instantly share code, notes, and snippets.

@earvinpiamonte
Created October 26, 2020 05:19
Show Gist options
  • Save earvinpiamonte/7de9813dfadde2306d834e97c7ed321f to your computer and use it in GitHub Desktop.
Save earvinpiamonte/7de9813dfadde2306d834e97c7ed321f to your computer and use it in GitHub Desktop.
Webpack setup with Tailwind CSS
const mix = require("laravel-mix");
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel applications. By default, we are compiling the CSS
| file for the application as well as bundling up all the JS files.
|
*/
const ENV = process.env;
const filesToWatch = [
"app/**/*.php",
"resources/views/**/*.php",
"public/js/**/*.js",
"public/css/**/*.css"
];
mix.browserSync({
host: ENV.APP_URL.replace("http://", "").replace("https://", ""),
proxy: ENV.APP_URL,
open: false,
files: filesToWatch,
watchOptions: {
usePolling: true
}
})
.js("resources/js/app.js", "public/js")
.postCss("resources/css/app.css", "public/css", [
require("tailwindcss"),
require("autoprefixer")
])
.disableNotifications();
if (mix.inProduction()) {
mix.version();
}
@earvinpiamonte
Copy link
Author

Add serve to the package.json.

eg. stripped package.json

{
   ...
    "scripts": {
        ...
        "serve": "npm run watch-poll",
    },
    "devDependencies": {
        ...
    },
    "dependencies": {
        ...
    }
}

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