Skip to content

Commit

Permalink
Fixed bugs, added font-icon generator, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
voidgraphics committed Jun 26, 2020
1 parent 40dc0e4 commit 041377d
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 12 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Whitecube Laravel Preset

This preset will install and setup everything that is needed for new Laravel projects at Whitecube.

To start a new project:

```
// Creating the new Laravel project
laravel new my-project
cd my-project
// Installing the preset
composer require whitecube/laravel-preset
// Activating the preset
php artisan ui whitecube
// Installing front-end dependencies
yarn
// You're done! You can now compile, watch, etc!
yarn dev
yarn watch
yarn icons
yarn watch-icons
```

Everything you'd expect should be there, and you can get to work right away.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
],
"require": {
"php": "^7.1",
"illuminate/support": "^6.0",
"laravel/ui": "^1.0.0"
"laravel/ui": "^2.0"
},
"require-dev": {
"orchestra/testbench": "^4.0",
Expand All @@ -38,4 +37,4 @@
"providers": ["Whitecube\\LaravelPreset\\WhitecubeServiceProvider"]
}
}
}
}
18 changes: 18 additions & 0 deletions src/Assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Whitecube\LaravelPreset;

use \File;

class Assets
{

public static function install()
{
File::ensureDirectoryExists('resources/img');
File::ensureDirectoryExists('resources/fonts');
File::ensureDirectoryExists('resources/icons');
File::ensureDirectoryExists('resources/favicon');
}

}
29 changes: 28 additions & 1 deletion src/Mix.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static function install()
{
static::copyFile();
static::setBrowserSyncDomain();
static::addNpmScripts();
}

public static function copyFile()
Expand All @@ -25,4 +26,30 @@ public static function setBrowserSyncDomain()
File::put(base_path() . '/webpack.mix.js', $mix);
}

}
public static function addNpmScripts()
{
if (! file_exists(base_path('package.json'))) {
return;
}

$packages = json_decode(file_get_contents(base_path('package.json')), true);

$packages['scripts'] = static::updateNpmScripts(
array_key_exists('scripts', $packages) ? $packages['scripts'] : []
);

file_put_contents(
base_path('package.json'),
json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL
);
}

public static function updateNpmScripts($scripts)
{
return array_merge($scripts, [
'icons' => 'BUILD_ICONS=true yarn dev',
'watch-icons' => 'BUILD_ICONS=true yarn watch',
]);
}

}
2 changes: 1 addition & 1 deletion src/Pluton.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function prepareFiles()
{
File::cleanDirectory(resource_path('js'));
copy(__DIR__ . '/stubs/js/app.js', resource_path('js/app.js'));
File::makeDirectory('resources/js/parts');
File::ensureDirectoryExists('resources/js/parts');
copy(__DIR__.'/stubs/js/part.js', resource_path('js/parts/example.js'));
}

Expand Down
6 changes: 6 additions & 0 deletions src/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ public static function install()
Mix::install();
Pluton::install();
Sass::install();
Assets::install();
}

public static function updatePackageArray($packages)
{
return array_merge(
[
'laravel-mix-pluton' => '^1.0.4',
'whitecube-pluton' => '1.0.2',
'mix-white-sass-icons' => '^0.0.4',
'@babel/plugin-proposal-class-properties' => '^7.8.3',
'@babel/plugin-proposal-nullish-coalescing-operator' => '^7.8.3',
'vue-template-compiler' => '^2.6.10',
"browser-sync" => "^2.26.7",
"browser-sync-webpack-plugin" => "^2.0.1"
],
Arr::except($packages, [
'vue',
Expand Down
7 changes: 2 additions & 5 deletions src/Sass.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ public static function addEntry()

public static function addBase()
{
if(!File::exists('resources/sass/base')) {
File::makeDirectory('resources/sass/base');
}
File::ensureDirectoryExists('resources/sass/base');

if(!File::exists('resources/sass/base/_reset.scss')) {
copy(__DIR__ . '/stubs/css/reset.scss', resource_path('sass/base/_reset.scss'));
}


if(!File::exists('resources/sass/base/_base.scss')) {
copy(__DIR__ . '/stubs/css/base.scss', resource_path('sass/base/_base.scss'));
}
Expand All @@ -55,4 +52,4 @@ public static function addBase()
}
}

}
}
6 changes: 5 additions & 1 deletion src/stubs/css/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ body {
max-width: 90%;
margin: 0 auto;
position: relative;

&.grid {
@include grid;
}
}

.sro {
Expand All @@ -23,4 +27,4 @@ body {

*:focus {
outline: none;
}
}
6 changes: 5 additions & 1 deletion src/stubs/webpack.mix.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const mix = require('laravel-mix');
require('laravel-mix-pluton');
require('mix-white-sass-icons');

/*
|--------------------------------------------------------------------------
Expand All @@ -12,11 +13,14 @@ require('laravel-mix-pluton');
|
*/

if(process.env.BUILD_ICONS) {
return mix.icons('resources/icons', 'resources/fonts')
}

mix.pluton('resources/js/parts')
.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.copy('resources/img', 'public/img')
.copy('resources/fonts', 'public/fonts')
.copy('resources/favicon', 'public/favicon')
.browserSync({
proxy: '#DOMAIN#.localhost',
Expand Down

0 comments on commit 041377d

Please sign in to comment.