├── LICENSE.md ├── README.md ├── composer.json └── src ├── Preset.php ├── PresetServiceProvider.php └── stubs ├── app.js ├── bootstrap.js ├── gitignore-stub ├── resources └── css │ └── app.css ├── views ├── layouts │ └── app.blade.php └── welcome.blade.php └── webpack.mix.js /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Adam Wathan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > **Note: This is no longer maintained as I don't actually use it myself, I just set this stuff up from scratch each time since it only takes a minute to do and Laravel 6 ships with less boilerplate to delete.** 2 | 3 | # 🚀 Adam Wathan's Laravel Frontend Preset 4 | 5 | A Laravel frontend preset that scaffolds out new applications just the way I like 'em 👌🏻 6 | 7 | What it includes: 8 | 9 | - [Tailwind CSS](https://tailwindcss.com) 10 | - [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) for nested CSS support 11 | - [Purgecss](https://www.purgecss.com/), via [spatie/laravel-mix-purgecss](https://github.com/spatie/laravel-mix-purgecss) 12 | - [Vue.js](https://vuejs.org/) 13 | - Removes Bootstrap and jQuery 14 | - Adds compiled assets to `.gitignore` 15 | - Adds a simple Tailwind-tuned default layout template 16 | - Replaces the `welcome.blade.php` template with one that extends the main layout 17 | 18 | ## Installation 19 | 20 | This package isn't on Packagist (yet), so to get started, add it as a repository to your `composer.json` file: 21 | 22 | ```json 23 | "repositories": [ 24 | { 25 | "type": "vcs", 26 | "url": "https://github.com/adamwathan/laravel-preset" 27 | } 28 | ] 29 | ``` 30 | 31 | Next, run this command to add the preset to your project: 32 | 33 | ``` 34 | composer require adamwathan/laravel-preset --dev 35 | ``` 36 | 37 | Finally, apply the scaffolding by running: 38 | 39 | ``` 40 | php artisan preset nothingworks 41 | ``` 42 | 43 | > What's `nothingworks`? NothingWorks Inc. is the absurd name I chose for my business, where I create products like [Refactoring to Collections](https://adamwathan.me/refactoring-to-collections/) and [Test-Driven Laravel](https://course.testdrivenlaravel.com/) 😄 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "adamwathan/laravel-preset", 3 | "description": "Adam Wathan's Laravel Frontend Preset", 4 | "keywords": ["laravel", "preset"], 5 | "license": "MIT", 6 | "require": { 7 | "laravel/framework": "^5.7" 8 | }, 9 | "autoload": { 10 | "psr-4": { 11 | "NothingWorks\\LaravelPreset\\": "src/" 12 | } 13 | }, 14 | "extra": { 15 | "laravel": { 16 | "providers": [ 17 | "NothingWorks\\LaravelPreset\\PresetServiceProvider" 18 | ] 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Preset.php: -------------------------------------------------------------------------------- 1 | '^2.2.0', 28 | 'postcss-nesting' => '^5.0.0', 29 | 'postcss-import' => '^11.1.0', 30 | 'tailwindcss' => '>=0.5.3', 31 | ], Arr::except($packages, [ 32 | 'bootstrap', 33 | 'bootstrap-sass', 34 | 'jquery', 35 | 'popper.js', 36 | ])); 37 | } 38 | 39 | protected static function updateWebpackConfiguration() 40 | { 41 | copy(__DIR__.'/stubs/webpack.mix.js', base_path('webpack.mix.js')); 42 | } 43 | 44 | protected static function updateStyles() 45 | { 46 | tap(new Filesystem, function ($files) { 47 | $files->deleteDirectory(resource_path('sass')); 48 | $files->delete(public_path('js/app.js')); 49 | $files->delete(public_path('css/app.css')); 50 | 51 | if (! $files->isDirectory($directory = resource_path('css'))) { 52 | $files->makeDirectory($directory, 0755, true); 53 | } 54 | }); 55 | 56 | copy(__DIR__.'/stubs/resources/css/app.css', resource_path('css/app.css')); 57 | } 58 | 59 | protected static function updateJavaScript() 60 | { 61 | copy(__DIR__.'/stubs/app.js', resource_path('js/app.js')); 62 | copy(__DIR__.'/stubs/bootstrap.js', resource_path('js/bootstrap.js')); 63 | } 64 | 65 | protected static function updateTemplates() 66 | { 67 | tap(new Filesystem, function ($files) { 68 | $files->delete(resource_path('views/home.blade.php')); 69 | $files->delete(resource_path('views/welcome.blade.php')); 70 | $files->copyDirectory(__DIR__.'/stubs/views', resource_path('views')); 71 | }); 72 | } 73 | 74 | protected static function updateGitignore() 75 | { 76 | copy(__DIR__.'/stubs/gitignore-stub', base_path('.gitignore')); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/PresetServiceProvider.php: -------------------------------------------------------------------------------- 1 | info('NothingWorks scaffolding installed successfully.'); 16 | $command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); 17 | }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/stubs/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | window.Vue = require('vue'); 11 | 12 | /** 13 | * Next, we will create a fresh Vue application instance and attach it to 14 | * the page. Then, you may begin adding components to this application 15 | * or customize the JavaScript scaffolding to fit your unique needs. 16 | */ 17 | 18 | Vue.component('example-component', require('./components/ExampleComponent.vue')); 19 | 20 | const app = new Vue({ 21 | el: '#app' 22 | }); 23 | -------------------------------------------------------------------------------- /src/stubs/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | 4 | /** 5 | * We'll load the axios HTTP library which allows us to easily issue requests 6 | * to our Laravel back-end. This library automatically handles sending the 7 | * CSRF token as a header based on the value of the "XSRF" token cookie. 8 | */ 9 | 10 | window.axios = require('axios'); 11 | 12 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 13 | 14 | /** 15 | * Next we will register the CSRF Token as a common header with Axios so that 16 | * all outgoing HTTP requests automatically have it attached. This is just 17 | * a simple convenience so we don't have to attach every token manually. 18 | */ 19 | 20 | let token = document.head.querySelector('meta[name="csrf-token"]'); 21 | 22 | if (token) { 23 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 24 | } else { 25 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 26 | } 27 | 28 | /** 29 | * Echo exposes an expressive API for subscribing to channels and listening 30 | * for events that are broadcast by Laravel. Echo and event broadcasting 31 | * allows your team to easily build robust real-time web applications. 32 | */ 33 | 34 | // import Echo from 'laravel-echo' 35 | 36 | // window.Pusher = require('pusher-js'); 37 | 38 | // window.Echo = new Echo({ 39 | // broadcaster: 'pusher', 40 | // key: 'your-pusher-key', 41 | // cluster: 'mt1', 42 | // encrypted: true 43 | // }); 44 | -------------------------------------------------------------------------------- /src/stubs/gitignore-stub: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /public/build 5 | /public/css 6 | /public/js 7 | /public/mix-manifest.json 8 | /storage/*.key 9 | /vendor 10 | /.idea 11 | /.vscode 12 | /.vagrant 13 | Homestead.json 14 | Homestead.yaml 15 | npm-debug.log 16 | yarn-error.log 17 | .env 18 | -------------------------------------------------------------------------------- /src/stubs/resources/css/app.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss/preflight"; 2 | 3 | /* Add custom base styles here... */ 4 | 5 | @import "tailwindcss/components"; 6 | 7 | /* Add custom components here... */ 8 | 9 | @import "tailwindcss/utilities"; 10 | 11 | /* Add custom utilities here... */ 12 | -------------------------------------------------------------------------------- /src/stubs/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 |