1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

laravel10-React環境構築(メモ)

Last updated at Posted at 2023-11-17

laradockダウンロード

コンテナ起動

sudo docker compose up -d nginx postgres pgadmin

bashログイン

docker compose exec workspace bash

laravel10 ダウンロード

composer create-project laravel/laravel .

Composerを使用して、Laravel Breezeパッケージをプロジェクト追加

composer require laravel/breeze --dev

Breezeパッケージをインストールし、Reactをフロントエンドフレームワークとして設定

php artisan breeze:install react

フロントサーバの起動に必要な初回のみ実行

nvm install 20.5.0
nvm use 20.5.0
npm install -g npm@10.2.2
npm install

フロントサーバの起動

npm run dev

app.phpの編集

ダミーデータ作成のために、日本語化しておきます。

‘locale’ => ‘ja’,
‘fallback_locale’ => ‘ja’,
‘faker_locale’ => ‘ja_JP’,

データベース情報の設定

DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret

vite.config.js

import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import react from "@vitejs/plugin-react";

export default defineConfig({
    plugins: [
        laravel({
            input: "resources/js/app.jsx",
            refresh: true,
        }),
        react(),
    ],
    // 以下追加
    server: {
        host: true,
        hmr: {
            host: "localhost",
        },
    },
});

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?