From 77c4b048a7d95ea6e7ba08d3d0ec33728450d459 Mon Sep 17 00:00:00 2001 From: ravenberg Date: Wed, 1 Jan 2020 16:29:49 +0100 Subject: [PATCH] Configuring the proxy server based on the directory name --- README.md | 7 ++++--- src/InertiaReactPreset.php | 11 +++++++++-- src/InertiaReactPresetServiceProvider.php | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 86b7af1..a21ed2f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # Inertia React Laravel ui preset 💜 -Leverage ReactJS as your view layer within Laravel. This is a - preset to setup [Inertia](https://inertiajs.com/) and [React](https://reactjs.org/) within a fresh Laravel installation. By using this, you get front-end scaffolding including authentication. Tailwind is setup as well. +Leverage ReactJS as your view layer within your Laravel application. This is a + preset to setup [Inertia](https://inertiajs.com/) + [React](https://reactjs.org/) within a fresh Laravel installation. By using this, you get front-end scaffolding including authentication. Tailwind is setup as well. -The benefit of using Inertia is how you are able to use Laravel and all its features while having a modern front-end along with that modern front-end development workflow; +The benefit of using Inertia is how you are able to use Laravel and all its beloved features while having a modern front-end along with that modern front-end development workflow; ``` $ npm run hot ``` +> A proxy server is started with hot reloading. If you are not using Laravel Valet you may have to change the proxy url within your webpack.mix.js file. ## Setup Follow these 3 steps to execute the scaffolding using this preset. diff --git a/src/InertiaReactPreset.php b/src/InertiaReactPreset.php index 6a5d3e4..14c1a69 100644 --- a/src/InertiaReactPreset.php +++ b/src/InertiaReactPreset.php @@ -97,11 +97,18 @@ protected static function updateComposerArray(array $packages) } /** - * Override the webpack.mix.js file with the preset's one + * Override the webpack.mix.js file with the preset's one and configure it */ public static function configureMix() { - File::copy(__DIR__.'/stubs/webpack.mix.js', base_path('webpack.mix.js')); + $webpackConfigBasePath = base_path('webpack.mix.js'); + File::copy(__DIR__.'/stubs/webpack.mix.js', $webpackConfigBasePath); + $rootDirectoryName = Arr::last(explode('/', base_path())); + file_put_contents($webpackConfigBasePath, str_replace( + 'laravel.test', + $rootDirectoryName . '.test', + file_get_contents($webpackConfigBasePath) + )); } /** diff --git a/src/InertiaReactPresetServiceProvider.php b/src/InertiaReactPresetServiceProvider.php index 5347f10..8dc1161 100644 --- a/src/InertiaReactPresetServiceProvider.php +++ b/src/InertiaReactPresetServiceProvider.php @@ -16,7 +16,7 @@ public function boot() PresetCommand::macro('inertia-react', function(Command $command) { InertiaReactPreset::install($command); $command->info('🎉 Inertiajs with Reactjs scaffolding complete.'); - $command->info('ℹī¸ Don\'t forget to run npm install && npm run dev'); + $command->info('Don\'t forget to run npm install && npm run dev'); }); } }