Skip to content

Commit 1440903

Browse files
Update the preset to use laravel-mix-tailwind (#28)
* switch to use laravel-mix-tailwind * exclude laravel-mix from package.json so we can explicitly define required version * change main.css to app.css to be consistent with default Laravel install * update readme * update command info * Remove comments for LESS/SASS preprocessing. The `laravel-mix-tailwind` plugin handles this for us, so there's nothing exceptional you need to do if you want to use `mix.less()` or `mix.sass()` any more.
1 parent 0af0b1f commit 1440903

File tree

7 files changed

+21
-36
lines changed

7 files changed

+21
-36
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
# Laravel 5.5.x/5.6.x Frontend preset for Tailwind CSS
1+
# Laravel 5.5+ Frontend preset for Tailwind CSS
22

33
A Laravel front-end scaffolding preset for [Tailwind CSS](https://tailwindcss.com) - a Utility-First CSS Framework for Rapid UI Development.
44

55
*Current version:* **Tailwind CSS 0.5.2**
66

77
## Usage
88

9-
1. Fresh install Laravel 5.5.x or 5.6.x and cd to your app.
10-
2. Install this preset via `composer require laravel-frontend-presets/tailwindcss`. Laravel >= 5.5.0 will automatically discover this package. No need to register the service provider.
9+
1. Fresh install Laravel >= 5.5.0 and cd to your app.
10+
2. Install this preset via `composer require laravel-frontend-presets/tailwindcss`. Laravel will automatically discover this package. No need to register the service provider.
1111
3. Use `php artisan preset tailwindcss` for the basic Tailwind CSS preset OR use `php artisan preset tailwindcss-auth` for the basic preset, auth route entry and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`)
12-
4. `npm install`
13-
5. `npm run dev`
14-
6. Configure your favorite database (mysql, sqlite etc.)
15-
7. `php artisan migrate` to create basic user tables.
16-
8. `php artisan serve` (or equivalent) to run server and test preset.
12+
4. `npm install && npm run dev && npm run dev` (this is required twice, due to the way that `laravel-mix-tailwind` installs the Tailwind CSS dependency)
13+
5. Configure your favorite database (mysql, sqlite etc.)
14+
6. `php artisan migrate` to create basic user tables.
15+
7. `php artisan serve` (or equivalent) to run server and test preset.
1716

1817
### Changing colours
1918

src/TailwindCssPreset.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ public static function installAuth()
2727
protected static function updatePackageArray(array $packages)
2828
{
2929
return array_merge([
30+
'laravel-mix' => '^2.1',
3031
'laravel-mix-purgecss' => '^2.0',
31-
'tailwindcss' => '>=0.5.2',
32+
'laravel-mix-tailwind' => '^0.1.0',
3233
], Arr::except($packages, [
3334
'bootstrap',
3435
'bootstrap-sass',
36+
'laravel-mix',
3537
'jquery',
3638
'popper.js',
3739
]));
@@ -49,7 +51,7 @@ protected static function updateStyles()
4951
}
5052
});
5153

52-
copy(__DIR__.'/tailwindcss-stubs/resources/assets/css/main.css', resource_path('assets/css/main.css'));
54+
copy(__DIR__.'/tailwindcss-stubs/resources/assets/css/app.css', resource_path('assets/css/app.css'));
5355
}
5456

5557
protected static function updateBootstrapping()

src/TailwindCssPresetServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public function boot()
1313
TailwindCssPreset::install();
1414

1515
$command->info('Tailwind CSS scaffolding installed successfully.');
16-
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
16+
$command->info('Please run "npm install && npm run dev && npm run dev" to compile your fresh scaffolding.');
1717
});
1818

1919
PresetCommand::macro('tailwindcss-auth', function ($command) {
2020
TailwindCssPreset::installAuth();
2121

2222
$command->info('Tailwind CSS scaffolding with auth views installed successfully.');
23-
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
23+
$command->info('Please run "npm install && npm run dev && npm run dev" to compile your fresh scaffolding.');
2424
});
2525
}
2626
}

src/tailwindcss-stubs/resources/views/layouts/app.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<title>{{ config('app.name', 'Laravel') }}</title>
1212

1313
<!-- Styles -->
14-
<link href="{{ asset('css/main.css') }}" rel="stylesheet">
14+
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
1515
</head>
1616
<body class="bg-brand-lightest h-screen">
1717
<div id="app">

src/tailwindcss-stubs/resources/views/welcome.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<title>{{ config('app.name', 'Laravel') }}</title>
1212

1313
<!-- Styles -->
14-
<link href="{{ asset('css/main.css') }}" rel="stylesheet">
14+
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
1515
</head>
1616
<body class="bg-brand-lightest font-sans font-normal">
1717
<div class="flex flex-col">

src/tailwindcss-stubs/webpack.mix.js

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let mix = require("laravel-mix");
2-
let tailwindcss = require("tailwindcss");
2+
3+
require("laravel-mix-tailwind");
34
require("laravel-mix-purgecss");
45

56
/*
@@ -13,28 +14,11 @@ require("laravel-mix-purgecss");
1314
|
1415
*/
1516

16-
mix
17-
.js("resources/assets/js/app.js", "public/js")
18-
.postCss("resources/assets/css/main.css", "public/css", [
19-
tailwindcss("./tailwind.js")
20-
])
21-
.purgeCss();
17+
mix.js("resources/assets/js/app.js", "public/js")
18+
.postCss("resources/assets/css/app.css", "public/css")
19+
.tailwind()
20+
.purgeCss();
2221

2322
if (mix.inProduction()) {
2423
mix.version();
2524
}
26-
27-
// If you want to use LESS for your preprocessing
28-
// mix.less('resources/assets/less/main.less', 'public/css')
29-
// .options({
30-
// postCss: [
31-
// tailwindcss('./tailwind.js'),
32-
// ]
33-
// })
34-
35-
// If you want to use SASS for preprocessing
36-
// mix.sass('resources/assets/sass/app.scss', 'public/css')
37-
// .options({
38-
// processCssUrls: false,
39-
// postCss: [ tailwindcss('tailwind.js') ],
40-
// });

0 commit comments

Comments
 (0)