3
1

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.

Laravel 10.x + ViteでBootstrapを使う

Posted at

まずはよくある手順通りに準備

# プロジェクトの作成
composer create-project --prefer-dist laravel/laravel sample-app
cd sample-app

# laravel/uiのインストール
composer require laravel/ui

# Bootstrapの有効化
php artisan ui bootstrap

# Bootstrap等のインストール
npm i

ここが違う

公式ではblade.phpでのリソースの読み込みのコードとして以下のように書かれています。

@vite(['resources/css/app.css', 'resources/js/app.js'])

しかし、上記の手順で/vite-config.jsには以下のように書かれます。

input: [
    'resources/sass/app.scss',
    'resources/js/app.js',
],

/resources/css/app.cssは空なので、もちろんBootstrapは読み込まれません。

つまり、以下のようにリソースを読み込みます。

@vite(['resources/sass/app.scss', 'resources/js/app.js'])

参考

3
1
1

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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?