{"id":10168,"date":"2022-03-21T07:00:29","date_gmt":"2022-03-20T22:00:29","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=10168"},"modified":"2022-03-11T05:40:47","modified_gmt":"2022-03-10T20:40:47","slug":"__trashed-3","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=10168","title":{"rendered":"Laravel 9.x \u3067\u9ad8\u901f\u30d3\u30eb\u30c9\u30c4\u30fc\u30eb\u300cVite\u300d\u3092\u4f7f\u3063\u3066\u307f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u306f\u904e\u53bb\u8a18\u4e8b\u3067\u4f55\u56de\u304b\u66f8\u3044\u305f\u3053\u3068\u304c\u3042\u308b\u3093\u3067\u3059\u304c\u3001\u79c1\u306b\u306f\u300c<strong>\u3042\u307e\u308a\u597d\u304d\u3067\u306f\u306a\u3044\u30c6\u30af\u30ce\u30ed\u30b8\u30fc<\/strong>\u300d\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u304c\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u30d3\u30eb\u30c9\uff08\u30c8\u30e9\u30f3\u30b9\u30d1\u30a4\u30eb\uff09<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u300c<strong>\u30d3\u30eb\u30c9<\/strong>\u300d\u3068\u3044\u3046\u306e\u306f\u3001\uff08\u3044\u304f\u3064\u304b\u5f79\u5272\u304c\u3042\u308b\u306e\u3067\u3059\u304c\uff09\u3068\u3066\u3082\u30b7\u30f3\u30d7\u30eb\u306b\u8a00\u3046\u3068\u3001\u300c<strong>\u7701\u7565\u3057\u3066\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u3092\u30d6\u30e9\u30a6\u30b6\u304c\u8aad\u3081\u308b\u5f62\u306b\u76f4\u3057\u3066\u304f\u308c\u308b<\/strong>\u300d\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u4e8b\u81ea\u4f53\u306f\u3068\u3066\u3082\u6c17\u306b\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u3067\u3082\u79c1\u304c\u958b\u767a\u306b\u3042\u307e\u308a\u63a1\u7528\u3057\u3066\u306a\u3044\u7406\u7531\u304c\u300c<strong>\u30d3\u30eb\u30c9\u306b\u306f\u305d\u306e\u90fd\u5ea6\u6642\u9593\u304c\u304b\u304b\u308b<\/strong>\u300d\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u30c6\u30f3\u30dd\u304c\u300c<strong>\u30d3\u30eb\u30c9\u5f85\u3061<\/strong>\u300d\u306b\u3088\u3063\u3066\u5f37\u5236\u30b9\u30c8\u30c3\u30d7\u3055\u308c\u3001<strong>\u982d\u306e\u4e2d\u306b\u3042\u3063\u305f\u300c\u6226\u7565\u300d\u304c\u3059\u3063\u3068\u3093\u3067\u3057\u307e\u3046<\/strong>\u304b\u3089\u3067\u3059\u3002\uff08\u5f85\u3063\u3066\u308b\u9593\u3001\u3044\u308d\u3093\u306a\u3053\u3068\u8003\u3048\u3061\u3083\u3046\u96c6\u4e2d\u529b\u306e\u306a\u3044\u30e4\u30c4\u306a\u3093\u3067\u3059\u2026\ud83d\ude2d\uff09<\/p>\n<p>\u305f\u3060\u3001\u5c11\u3057\u524d\u306b\u3053\u306e\u300c\u5f85\u3061\u300d\u3092\u3059\u3063\u98db\u3070\u3057\u3066\u304f\u308c\u308b\u6280\u8853\u304c\u3042\u308b\u3053\u3068\u3092\u77e5\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u304c\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">Vite<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u203b <code>Vite<\/code>\u306f\u30d5\u30e9\u30f3\u30b9\u8a9e\u3067\u3001\u65e5\u672c\u8a9e\u3067\u306f\u300c\u7802\u7cd6\u5927\u6839\u300d\u3084\u300c\u5192\u967a\u738b\u300d\u306e\u3088\u3046\u306b\u300c\u30d3\u30fc\u30c8\u300d\u3068\u8aad\u3080\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f\u3001<code>Laravel-Mix<\/code>\u306e\u4ee3\u308f\u308a\u306b<code>Vite<\/code>\u3092\u4f7f\u3063\u3066\u30d3\u30eb\u30c9\u74b0\u5883\u3092\u8a66\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\ud83d\ude04\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2173 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png\" alt=\"\" width=\"300\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24-281x300.png 281w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>\u300c<code>Vite<\/code>\u3068<code>Vue<\/code>\u306e\u4f5c\u8005\u306f\u540c\u3058\u3067\u3059\u3002<br \/>\n\u5929\u624d\u3067\u3059\u306d\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 9.x<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p><code>Laravel Vite<\/code>\u3092\u52d5\u304b\u3059\u306b\u306f\u3001\u3044\u304f\u3064\u304b\u8981\u4ef6\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u305d\u306e\u4e2d\u3067\u3082\u91cd\u8981\u306a\uff12\u3064\u3067\u3059\u3002<br \/>\n\u3082\u3057\u74b0\u5883\u304c\u6574\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u5148\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>PHP 8.0 \u4ee5\u4e0a<\/li>\n<li>Node 16 \u4ee5\u4e0a<\/li>\n<\/ul>\n<p>\u203b \u305d\u306e\u4ed6\u306e\u8981\u4ef6\u306f <a href=\"http:\/\/npx @preset\/cli apply laravel:vite\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089<\/a><\/p>\n<p>\u307e\u305f\u3001<code>Ubuntu<\/code>\u306b<code>Node 16<\/code>\uff08<code>LTS<\/code>\uff09\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u65b9\u6cd5\u306f\u300c<a href=\"#install-node-16-in-ubuntu-20\">\u3061\u306a\u307f\u306b\uff1a Ubuntu 20.04 \u306b Node 16 \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/a>\u300d\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u306a\u304a\u3001\u300c<strong>Vite\u3092\u4f7f\u3046 \uff1d Webpack\uff08Laravel Mix\uff09\u3092\u4f7f\u308f\u306a\u304f\u3059\u308b<\/strong>\u300d\u3068\u3044\u3046\u3053\u3068\u306a\u306e\u3067\u3001\u65e2\u5b58\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u306a\u3069\u30d5\u30a9\u30eb\u30c0\u69cb\u6210\u304c\u5909\u66f4\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u307e\u305a\u306f\u65b0\u898f\u306b<code>Laravel<\/code>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u9806\u3092\u8ffd\u3063\u3066\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>webpack.mix.js \u3092\u524a\u9664<\/h1>\n<p><code>Webpack<\/code> \u2192 <code>Vite<\/code> \u3078\u79fb\u884c\u3059\u308b\u306e\u3067\u3001<code>Laravel<\/code>\u306e\u30d5\u30a9\u30eb\u30c0\u76f4\u4e0b\u306b\u3042\u308b<code>webpack.mix.js<\/code>\u306f\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10171\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_2.png\" alt=\"\" width=\"295\" height=\"581\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_2.png 295w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_2-152x300.png 152w\" sizes=\"auto, (max-width: 295px) 100vw, 295px\" \/><\/p>\n<h1>Laravel Mix \u3092\u30a2\u30f3\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u6b21\u306b\u3001<code>Laravel Mix<\/code>\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3082\u4e0d\u8981\u306a\u306e\u3067\u524a\u9664\u3057\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>npm remove laravel-mix<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u3001<code>package.json<\/code>\u304b\u3089\u3082<code>laravel-mix<\/code>\u304c\u6d88\u3048\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>composer \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h2>\n<p>\u6b21\u306b\u3001<code>Laravel<\/code>\u3067<code>Vite<\/code>\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u30d1\u30c3\u30b1\u30fc\u30b8 <strong><a href=\"https:\/\/laravel-vite.dev\/\" target=\"_blank\" rel=\"noopener\">laravel-vite<\/a><\/strong> \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>composer require innocenzi\/laravel-vite:0.2.*<\/strong><\/pre>\n<p>\u203b \u3061\u306a\u307f\u306b\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u3059\u308b\u3068\u3001\u30b3\u30f3\u30d5\u30a3\u30b0\u30d5\u30a1\u30a4\u30eb<code>config\/vite.php<\/code>\u306b\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002\u7d30\u304b\u306a\u8a2d\u5b9a\u3092\u3057\u305f\u3044\u5834\u5408\u306f\u3053\u3061\u3089\u304b\u3089\u5909\u66f4\u3059\u308b\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan vendor:publish --tag=vite-config<\/strong><\/pre>\n<h2>npm \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u3001<code>Vite<\/code>\u3068\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<pre><strong>npm i -D vite vite-plugin-laravel @vitejs\/plugin-vue<\/strong><\/pre>\n<p>\u203b \u3061\u306a\u307f\u306b<code>-D<\/code>\u306f<code>--save-dev<\/code>\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n<h1>package.json\u3092\u66f8\u304d\u63db\u3048\u308b<\/h1>\n<p>\u6b21\u306b\u3001\u3082\u3046<code>laravel-mix<\/code>\u306f\u4f7f\u308f\u306a\u3044\u306e\u3067\u3001<code>vite<\/code>\u7528\u306b<code>package.json<\/code>\u3092\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<p><strong>package.json<\/strong><\/p>\n<pre>{\r\n    \"private\": true,\r\n    \"scripts\": {\r\n<strong>        \"dev\": \"vite\",<\/strong>\r\n<strong>        \"build\": \"vite build\"<\/strong>\r\n    },\r\n    \"devDependencies\": {\r\n        \"@vitejs\/plugin-vue\": \"^2.2.4\",\r\n        \"axios\": \"^0.25\",\r\n        \"lodash\": \"^4.17.19\",\r\n        \"postcss\": \"^8.1.14\",\r\n        \"vite\": \"^2.8.6\",\r\n        \"vite-plugin-laravel\": \"^0.2.0-beta.9\"\r\n    }\r\n}<\/pre>\n<p>\u203b \uff08\u79c1\u306e\u74b0\u5883\u3067\u306f\uff09\u306f\u3058\u3081<code>7<\/code>\u884c\u3042\u308a\u307e\u3057\u305f\u304c\u3001<code>2<\/code>\u884c\u306b\u7f6e\u304d\u63db\u3048\u307e\u3057\u305f\u3002<\/p>\n<h1>Vite\u304b\u3089JavaScript \u304c\u8aad\u307f\u8fbc\u3081\u308b\u3088\u3046\u306b\u3059\u308b<\/h1>\n<p>\u305d\u3057\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304b\u3089<code>Vite<\/code>\u306e<code>JavaScript<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3063\u3066\u3082\u3001\u3053\u308c\u306f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b<code>@vite<\/code>\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3060\u3051\u3067OK\u3067\u3059\uff01<\/p>\n<p>\u306a\u304a\u3001\u5f8c\u3067<code>Vue 3<\/code>\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u3064\u304f\u308b\u306e\u3067\u3001<code>&lt;div id=\"app\"&gt;&lt;\/div&gt;<\/code>\u3082\u4e00\u7dd2\u306b\u30bb\u30c3\u30c8\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>resources\/views\/welcome.blade.php<\/strong><\/p>\n<pre>        &lt;\/div&gt;\r\n\r\n        <strong>&lt;div id=\"app\"&gt;&lt;\/div&gt;<\/strong>\r\n        <strong>@vite<\/strong>\r\n\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u203b \u30c6\u30b9\u30c8\u3067\u3059\u306e\u3067\u3001<code>welcom.blade.php<\/code>\u306b\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u672c\u6765\u306f<code>layouts\/app.blade.php<\/code>\u306a\u3069\u306b\u30bb\u30c3\u30c8\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>Vite \u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u3064\u304f\u308b<\/h1>\n<p>\u305d\u3057\u3066\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<p><strong>vite.config.ts<\/strong><\/p>\n<pre><strong>import { defineConfig } from 'vite'<\/strong>\r\n<strong>import vue from '@vitejs\/plugin-vue'<\/strong>\r\n<strong>import laravel from 'vite-plugin-laravel'<\/strong>\r\n\r\n<strong>export default defineConfig({<\/strong>\r\n<strong>    plugins: [<\/strong>\r\n<strong>        vue(),<\/strong>\r\n<strong>        laravel()<\/strong>\r\n<strong>    ]<\/strong>\r\n<strong>})<\/strong><\/pre>\n<h1>require() \u3092 import \u5f62\u5f0f\u3078\u5909\u66f4<\/h1>\n<p>\u3053\u3053\u304c\u3061\u3087\u3063\u3068\u3081\u3093\u3069\u3046\u306a\u306e\u3067\u3059\u304c\u3001<code>Vite<\/code>\u306f<code>ESM<\/code>\u3067\u4f5c\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3001<code>app.js<\/code>\u4ee5\u4e0b\u306b\u3042\u308b\u5168\u3066\u306e<code>require()<\/code>\u3092<code>import<\/code>\u3078\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>resources\/js\/app.js<\/strong><\/p>\n<pre><strong>import '.\/bootstrap'<\/strong><\/pre>\n<p><strong>resources\/js\/bootstrap.js<\/strong><\/p>\n<pre><strong>import _ from 'lodash';<\/strong>\r\n\r\n\/\/ \u7701\u7565\r\n\r\n<strong>import axios from 'axios'<\/strong>\r\n\r\n<strong>axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';<\/strong>\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u203b \u3064\u307e\u308a\u3001\u4eca\u5f8c\u5225\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3082<code>require()<\/code>\u3067\u306f\u306a\u304f\u3001<code>import<\/code>\u3092\u4f7f\u3046\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>Vue\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u305b\u3063\u304b\u304f\u3067\u3059\u306e\u3067<code>Vue 3<\/code>\u3067\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u3064\u304f\u308a\u3001<strong>welcome.blade.php<\/strong>\u3067\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>resources\/js\/app.js<\/strong><\/p>\n<pre>import '.\/bootstrap'\r\n\r\n\/\/ \ud83d\udc47 \u3053\u3053\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\r\n\r\n<strong>import { createApp } from 'vue'<\/strong>\r\n\r\n<strong>import App from '.\/vue\/App.vue'<\/strong>\r\n<strong>createApp(App).mount('#app')<\/strong><\/pre>\n<p><strong>resources\/js\/vue\/App.vue<\/strong><\/p>\n<pre><strong>&lt;script setup&gt;<\/strong>\r\n\r\n<strong>  import { ref } from 'vue'<\/strong>\r\n\r\n<strong>  const count = ref(0)<\/strong>\r\n<strong>  const addCount = () =&gt; {<\/strong>\r\n\r\n<strong>    count.value++<\/strong>\r\n\r\n<strong>  }<\/strong>\r\n\r\n<strong>&lt;\/script&gt;<\/strong>\r\n\r\n<strong>&lt;template&gt;<\/strong>\r\n<strong>  &lt;button @click=\"addCount\"&gt;{{ count }} \u56de\u30af\u30ea\u30c3\u30af\u3057\u307e\u3057\u305f\uff01&lt;\/button&gt;<\/strong>\r\n<strong>&lt;\/template&gt;<\/strong><\/pre>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u3053\u3053\u307e\u3067\u6765\u305f\u3089<code>Vite<\/code>\u3092\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u306e\u3067\u3001\u5b9f\u969b\u306b\u8a66\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10219\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_3.png\" alt=\"\" width=\"442\" height=\"348\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_3.png 442w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_3-300x236.png 300w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/p>\n<p>\u306f\u3044\u2757<code>Vite<\/code>\u304c\u8d77\u52d5\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u300c<strong>http:\/\/******\/<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10220\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_4.png\" alt=\"\" width=\"395\" height=\"269\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_4.png 395w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_4-300x204.png 300w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u3055\u304d\u307b\u3069\u8ffd\u52a0\u3057\u305f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u4f55\u56de\u304b\u30af\u30ea\u30c3\u30af\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3069\u3046\u306a\u308b\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10222\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_5.png\" alt=\"\" width=\"155\" height=\"20\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_5.png 155w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_5-150x20.png 150w\" sizes=\"auto, (max-width: 155px) 100vw, 155px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u3061\u3083\u3093\u3068\u30ab\u30a6\u30f3\u30c8\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u30d6\u30ed\u30b0\u3067\u306f\u5206\u304b\u308a\u306b\u304f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001<strong><code>Vite<\/code>\u304c\u3069\u308c\u3060\u3051\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u5909\u66f4\u3092\u53cd\u6620\u3055\u305b\u3066\u304f\u308c\u308b\u304b<\/strong>\u3082\u78ba\u8a8d\u3057\u305f\u3044\u306e\u3067\u3001<span style=\"font-size: 1rem;\">\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u82f1\u8a9e\u30d0\u30fc\u30b8\u30e7\u30f3\u3078\u5909\u66f4\u3057\u3066\u307f\u307e\u3059\u3002<\/span><\/p>\n<pre>&lt;template&gt;\r\n  &lt;button @click=\"addCount\"&gt;<strong>Clicked count: {{ count }}<\/strong>&lt;\/button&gt;\r\n&lt;\/template&gt;<\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb\uff1f\uff1f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10223\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_6.png\" alt=\"\" width=\"105\" height=\"16\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_6.png 105w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_6-100x16.png 100w\" sizes=\"auto, (max-width: 105px) 100vw, 105px\" \/><\/p>\n<p>\u306f\u3044\u2757\u307b\u307c\u30d3\u30eb\u30c9\u3092\u4f7f\u308f\u306a\u3044\u306e\u3068\u540c\u3058\u3050\u3089\u3044\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u53cd\u6620\u3055\u308c\u307e\u3057\u305f\u3002<br \/>\n\u3057\u304b\u3082\u3059\u3054\u3044\u3053\u3068\u306b\u3001<strong>\u30af\u30ea\u30c3\u30af\u56de\u6570\u304c\u4fdd\u6301\u3055\u308c\u305f\u307e\u307e\u5909\u66f4\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n<p><code>Vite<\/code>\u304a\u305d\u308b\u3079\u3057\ud83d\ude32\u2728<\/p>\n<p>\u305d\u3057\u3066\u3001\u6700\u5f8c\u306b\u5b9f\u969b\u306b\u672c\u756a\u74b0\u5883\u7528\u306b\u30d3\u30eb\u30c9\u3067\u304d\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n\u307e\u305a\u3001\u73fe\u72b6\u306e\u30b3\u30de\u30f3\u30c9\u3092<code>Ctrl + C<\/code>\u3067\u30af\u30ea\u30a2\u3057\u3066\uff08\u2190\u74b0\u5883\u3067\u9055\u3046\u304b\u3082&#8230;\uff09\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>npm run build<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u306b\u306a\u308a\u30d3\u30eb\u30c9\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10225\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_7.png\" alt=\"\" width=\"370\" height=\"280\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_7.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_7-300x227.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n<p>\u3067\u306f\u3001<code>.env<\/code>\u306e<code>APP_ENV<\/code>\u3092<code>production<\/code>\u3078\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>.env<\/strong><\/p>\n<pre><strong>APP_ENV=production<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u4e00\u5ea6\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u3092\u30ea\u30ed\u30fc\u30c9\u3057\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10226\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_8.png\" alt=\"\" width=\"107\" height=\"17\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_8.png 107w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_8-100x17.png 100w\" sizes=\"auto, (max-width: 107px) 100vw, 107px\" \/><\/p>\n<p>\u306f\u3044\u2757\u5148\u307b\u3069\u3068\u540c\u3058\u304f\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3067\u306f\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u65b9\u3082\u78ba\u8a8d\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre>        &lt;\/div&gt;\r\n\r\n        &lt;div id=\"app\"&gt;&lt;\/div&gt;\r\n        \r\n        <strong>&lt;!-- \ud83d\udc47 \u3053\u3053\u304c Vite \u30b5\u30fc\u30d0\u30fc\u3067\u306f\u306a\u304f\u3001\u5b9f\u969b\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3057\u3066\u3044\u307e\u3059 --&gt;<\/strong>\r\n<strong>        &lt;script type=\"module\" src=\"http:\/\/vite-l9.test\/build\/assets\/app.d54f2625.js\"&gt;&lt;\/script&gt;<\/strong>\r\n    &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u306f\u3044\u2757<br \/>\n\u5b9f\u4f53\u306e\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude04\u2728<\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u5f93\u6765\u306e<code>laravel-mix<\/code>\u3068\u6bd4\u3079\u308b\u3068\u3001<code>Vite<\/code>\u306f\u306f\u308b\u304b\u306b\u9ad8\u901f\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u30b3\u30fc\u30c9\u3092\u5909\u66f4\u3059\u308b\u3054\u3068\u306b\u5fc5\u8981\u3068\u306a\u3063\u3066\u3044\u305f\u300c<strong>\u30d3\u30eb\u30c9\u5f85\u3061<\/strong>\u300d\u304c\u307b\u307c\u306a\u304f\u306a\u308b\u306e\u3067\u3001\u958b\u767a\u30c6\u30f3\u30dd\u304c\u3042\u304c\u308b\u3053\u3068\u304c\u671f\u5f85\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057<code>Laravel<\/code>\u306b<code>Vite<\/code>\u3092\u5c0e\u5165\u3055\u308c\u305f\u3044\u65b9\u306f\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002\ud83d\ude04\u2728<\/p>\n<h1 id=\"install-node-16-in-ubuntu-20\">\u3061\u306a\u307f\u306b\uff1a Ubuntu 20.04 \u306b Node 16 \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u79c1\u304c\u958b\u767a\u3067\u5229\u7528\u3057\u3066\u3044\u308b<code>Ubuntu<\/code>\uff08<code>Linux<\/code>\uff09\u306f\u6a19\u6e96\u3067\u306f<code>NodeJS<\/code>\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c<code>12<\/code>\u306e\u307e\u307e\u306a\u306e\u3067\u3001<code>LTS<\/code>\uff08\u9577\u30fc\u304f\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u30d0\u30fc\u30b8\u30e7\u30f3\uff09\u306e<code>16<\/code>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u3068\u8a00\u3063\u3066\u3082\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\uff12\u3064\u3092\u5b9f\u884c\u3059\u308b\u3060\u3051\u3067OK\u3067\u3059\ud83d\udc4d<\/p>\n<pre><strong>curl -fsSL https:\/\/deb.nodesource.com\/setup_16.x | sudo -E bash -\r\n<\/strong><\/pre>\n<pre><strong>sudo apt-get install -y nodejs<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<pre><strong>node --version<\/strong><\/pre>\n<p>\u5b9f\u969b\u306b\u3084\u3063\u3066\u307f\u3066\u7d50\u679c\u306f\u3053\u3061\u3089\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10169\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/03\/laravel_vite_1.png\" alt=\"\" width=\"86\" height=\"25\" \/><\/p>\n<p>\u5b8c\u4e86\u3067\u3059\ud83d\ude04\u2728<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u8d85\u9ad8\u901f\u306a\u30d3\u30eb\u30c9\u30c4\u30fc\u30eb<code>Vite<\/code>\u3092<code>Laravel<\/code>\u3067\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u611f\u60f3\u3068\u3057\u3066\u306f\u3001\u300c<strong>\u3061\u3087\u3063\u3068\u5909\u66f4\u3059\u308b\u90e8\u5206\u304c\u591a\u3044\u304b\u3089\u6700\u521d\u306f\u3081\u3093\u3069\u3046\u304b\u306a&#8230;\ud83d\ude05<\/strong>\u300d\u3068\u3044\u3046\u3082\u306e\u3067\u3057\u305f\u3002<\/p>\n<p>\u305f\u3060\u3001\u30db\u30f3\u30c8\u306b\u3053\u308c\u307e\u3067\u306e\u30d3\u30eb\u30c9\u6642\u9593\u3092\u8003\u3048\u308b\u3068\u300c\u30b9\u30ba\u30e1\u3068\u30bf\u30ab\u300d\u3050\u3089\u3044\u306e\u5dee\u3092\u611f\u3058\u307e\u3057\u305f\u306e\u3067\u3001\u4eca\u5f8c<code>Laravel 10<\/code>\u3068\u304b\u3067<code>Vite<\/code>\u304c\u63a1\u7528\u306b\u306a\u308b\u304b\u3001<code>Laravel-Mix<\/code>\u306e\u9078\u629e\u80a2\u306e\uff11\u3064\u3068\u3057\u3066\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u304f\u308c\u305f\u3089\u5b09\u3057\u3044\u306a\u3001\u306a\u3093\u3066\u8003\u3048\u3066\u307e\u3057\u305f\u3002<\/p>\n<p>\u3042\u3068\u3001\u5c11\u3057\u524d\u306b\u767a\u8868\u3055\u308c\u305f\u4ee5\u4e0b\u306e\u30cb\u30e5\u30fc\u30b9\u306b\u3082\u671f\u5f85\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong> <a href=\"https:\/\/www.publickey1.jp\/blog\/22\/javascripttypes_as_commentsjavascripttc39.html\" target=\"_blank\" rel=\"noopener\">\u30de\u30a4\u30af\u30ed\u30bd\u30d5\u30c8\u3001JavaScript\u306b\u578b\u5ba3\u8a00\u3092\u8ffd\u52a0\u3057\u3064\u3064\u30c8\u30e9\u30f3\u30b9\u30d1\u30a4\u30e9\u4e0d\u8981\u306e\u300cTypes as Comments\u300d\u3092JavaScript\u4ed5\u69d8\u7b56\u5b9a\u4f1a\u8b70\u306eTC39\u306b\u63d0\u6848\u3078<\/a><\/p>\n<p>\u7686\u3055\u3093\u306e\u3054\u610f\u898b\u306f\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n\u305c\u3072\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6066 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png\" alt=\"\" width=\"370\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2020\/03\/no_23-300x259.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/>\u300cYoshiki \u30b9\u30bf\u30a4\u30eb\u3067<br \/>\n\u30d4\u30a2\u30ce\u7df4\u7fd2\u3057\u3066\u307e\u3059\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u306f\u904e\u53bb\u8a18\u4e8b\u3067\u4f55\u56de\u304b\u66f8\u3044\u305f\u3053\u3068\u304c\u3042\u308b\u3093\u3067\u3059\u304c\u3001\u79c1\u306b\u306f\u300c\u3042\u307e\u308a\u597d\u304d\u3067\u306f\u306a\u3044\u30c6\u30af\u30ce\u30ed\u30b8\u30fc\u300d\u304c\u3042\u308a\u307e\u3059\u3002 \u305d\u308c\u304c\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb \u30d3\u30eb\u30c9\uff08\u30c8\u30e9\u30f3\u30b9\u30d1\u30a4\u30eb\uff09 \u3067 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=10168\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel 9.x \u3067\u9ad8\u901f\u30d3\u30eb\u30c9\u30c4\u30fc\u30eb\u300cVite\u300d\u3092\u4f7f\u3063\u3066\u307f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":10231,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,12],"tags":[245],"class_list":["post-10168","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-vue-js","tag-vite"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/10168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10168"}],"version-history":[{"count":20,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/10168\/revisions"}],"predecessor-version":[{"id":10242,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/10168\/revisions\/10242"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/10231"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}