Laravel with Vuejs
Laravel Mix
Use laravel-mix
to integrate Vuejs with Laravel. See this tutorial for reference.
Install
1 | npm install --save-dev laravel-mix |
You can also run npm install
in the working dir of laravel app
Vue component
By default, you have already an example in the folder resources/assets
1 |
|
1 |
|
Import Vue instance
Create an index page index.blade.php
Import the javasript.
1 |
|
Create the route
1 | Route::get('/', function () { |
Visit myapp.dev. You got the vue app integrated.
Configure Mix
Configure the file webpack.mix.js
1 | let mix = require('laravel-mix'); |
You can also change the webpack configuration by copying the filenode_modules/laravel-mix/setup/webpack.config.js
to working dir and customize it.
Change the entry in the package.json from
1 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", |
to
1 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=jebpack.config.js", |