Skip to content

Commit a37a1d6

Browse files
assume flattened resource structure for a fresh 5.7 app
1 parent e6911e0 commit a37a1d6

File tree

4 files changed

+17
-31
lines changed

4 files changed

+17
-31
lines changed

src/TailwindCssPreset.php

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,38 @@ protected static function updatePackageArray(array $packages)
2828
{
2929
return array_merge([
3030
'laravel-mix' => '^2.1',
31-
'laravel-mix-purgecss' => '^2.0',
31+
'laravel-mix-purgecss' => '^2.2',
3232
'laravel-mix-tailwind' => '^0.1.0',
3333
], Arr::except($packages, [
3434
'bootstrap',
3535
'bootstrap-sass',
3636
'laravel-mix',
3737
'jquery',
38-
'popper.js',
3938
]));
4039
}
4140

4241
protected static function updateStyles()
4342
{
4443
tap(new Filesystem, function ($filesystem) {
45-
$filesystem->deleteDirectory(resource_path(self::flattenPath('sass')));
44+
$filesystem->deleteDirectory(resource_path('sass'));
4645
$filesystem->delete(public_path('js/app.js'));
4746
$filesystem->delete(public_path('css/app.css'));
4847

49-
if (! $filesystem->isDirectory($directory = resource_path(self::flattenPath('css')))) {
48+
if (! $filesystem->isDirectory($directory = resource_path('css'))) {
5049
$filesystem->makeDirectory($directory, 0755, true);
5150
}
5251
});
5352

54-
copy(__DIR__.'/tailwindcss-stubs/resources/assets/css/app.css', resource_path(self::flattenPath('css/app.css')));
53+
copy(__DIR__.'/tailwindcss-stubs/resources/css/app.css', resource_path('css/app.css'));
5554
}
5655

5756
protected static function updateBootstrapping()
5857
{
5958
copy(__DIR__.'/tailwindcss-stubs/tailwind.js', base_path('tailwind.js'));
6059

61-
if (self::flattenResources()) {
62-
copy(__DIR__.'/tailwindcss-stubs/webpack57.mix.js', base_path('webpack.mix.js'));
63-
} else {
64-
copy(__DIR__.'/tailwindcss-stubs/webpack.mix.js', base_path('webpack.mix.js'));
65-
}
60+
copy(__DIR__.'/tailwindcss-stubs/webpack.mix.js', base_path('webpack.mix.js'));
6661

67-
copy(__DIR__.'/tailwindcss-stubs/resources/assets/js/bootstrap.js', resource_path(self::flattenPath('js/bootstrap.js')));
62+
copy(__DIR__.'/tailwindcss-stubs/resources/js/bootstrap.js', resource_path('js/bootstrap.js'));
6863
}
6964

7065
protected static function updateWelcomePage()
@@ -95,14 +90,4 @@ protected static function compileControllerStub()
9590
file_get_contents(__DIR__.'/tailwindcss-stubs/controllers/HomeController.stub')
9691
);
9792
}
98-
99-
private static function flattenResources()
100-
{
101-
return version_compare(app()->version(), '5.7.0', '>=');
102-
}
103-
104-
private static function flattenPath($path)
105-
{
106-
return ((self::flattenResources()) ? '' : 'assets/') . $path;
107-
}
10893
}

src/tailwindcss-stubs/resources/assets/js/bootstrap.js renamed to src/tailwindcss-stubs/resources/js/bootstrap.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
window._ = require("lodash");
1+
window._ = require('lodash');
2+
window.Popper = require('popper.js').default;
23

34
/**
45
* We'll load the axios HTTP library which allows us to easily issue requests
56
* to our Laravel back-end. This library automatically handles sending the
67
* CSRF token as a header based on the value of the "XSRF" token cookie.
78
*/
89

9-
window.axios = require("axios");
10+
window.axios = require('axios');
1011

11-
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
12+
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
1213

1314
/**
1415
* Next we will register the CSRF Token as a common header with Axios so that
@@ -19,11 +20,9 @@ window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
1920
let token = document.head.querySelector('meta[name="csrf-token"]');
2021

2122
if (token) {
22-
window.axios.defaults.headers.common["X-CSRF-TOKEN"] = token.content;
23+
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
2324
} else {
24-
console.error(
25-
"CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token"
26-
);
25+
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
2726
}
2827

2928
/**
@@ -38,5 +37,7 @@ if (token) {
3837

3938
// window.Echo = new Echo({
4039
// broadcaster: 'pusher',
41-
// key: 'your-pusher-key'
40+
// key: process.env.MIX_PUSHER_APP_KEY,
41+
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
42+
// encrypted: true
4243
// });

src/tailwindcss-stubs/webpack.mix.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ require("laravel-mix-purgecss");
1414
|
1515
*/
1616

17-
mix.js("resources/assets/js/app.js", "public/js")
18-
.postCss("resources/assets/css/app.css", "public/css")
17+
mix.js('resources/js/app.js', 'public/js')
18+
.postCss('resources/css/app.css', 'public/css')
1919
.tailwind()
2020
.purgeCss();
2121

0 commit comments

Comments
 (0)