Skip to content

Commit 0edefef

Browse files
committed
Add vitejs
1 parent ade173d commit 0edefef

File tree

9 files changed

+11374
-88
lines changed

9 files changed

+11374
-88
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/public/hot
33
/public/storage
44
/public/dist
5+
/public/build
56
/storage/*.key
67
/vendor
78
.env

package-lock.json

Lines changed: 11243 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,25 @@
77
"watch-poll": "mix watch -- --watch-options-poll=1000",
88
"hot": "mix watch --hot",
99
"prod": "npm run production",
10-
"production": "mix --production"
10+
"production": "mix --production",
11+
"build": "vite build",
12+
"preview": "vite preview"
1113
},
1214
"devDependencies": {
15+
"@popperjs/core": "^2.10.2",
16+
"@vitejs/plugin-vue": "^3.0.1",
1317
"axios": "^0.25",
18+
"bootstrap": "^5.1.3",
1419
"browser-sync": "^2.27.10",
1520
"browser-sync-webpack-plugin": "^2.3.0",
1621
"laravel-mix": "^6.0.49",
1722
"lodash": "^4.17.19",
1823
"postcss": "^8.1.14",
24+
"sass": "^1.32.11",
25+
"vue": "^3.2.37",
1926
"webpack-cli": "^4.10.0"
27+
},
28+
"dependencies": {
29+
"laravel-vite-plugin": "^0.5.4"
2030
}
2131
}

resources/js/app.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
require('./bootstrap');
1+
/**
2+
* First we will load all of this project's JavaScript dependencies which
3+
* includes Vue and other libraries. It is a great starting point when
4+
* building robust, powerful web applications using Vue and Laravel.
5+
*/
6+
7+
import './bootstrap';
8+
import { createApp } from 'vue';
9+
10+
/**
11+
* Next, we will create a fresh Vue application instance. You may then begin
12+
* registering components with the application instance so they are ready
13+
* to use in your application's views. An example is included for you.
14+
*/
15+
16+
const app = createApp({});
17+
18+
import ExampleComponent from './components/ExampleComponent.vue';
19+
app.component('example-component', ExampleComponent);
20+
21+
/**
22+
* The following block of code may be used to automatically register your
23+
* Vue components. It will recursively scan this directory for the Vue
24+
* components and automatically register them with their "basename".
25+
*
26+
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
27+
*/
28+
29+
// Object.entries(import.meta.globEager('./**/*.vue')).forEach(([path, definition]) => {
30+
// app.component(path.split('/').pop().replace(/\.\w+$/, ''), definition.default);
31+
// });
32+
33+
/**
34+
* Finally, we will attach the application instance to a HTML element with
35+
* an "id" attribute of "app". This element is included with the "auth"
36+
* scaffolding. Otherwise, you will need to add an element yourself.
37+
*/
38+
39+
app.mount('#app');

resources/js/bootstrap.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
window._ = require('lodash');
1+
import _ from 'lodash';
2+
window._ = _;
3+
4+
import 'bootstrap';
25

36
/**
47
* We'll load the axios HTTP library which allows us to easily issue requests
58
* to our Laravel back-end. This library automatically handles sending the
69
* CSRF token as a header based on the value of the "XSRF" token cookie.
710
*/
811

9-
window.axios = require('axios');
12+
import axios from 'axios';
13+
window.axios = axios;
1014

1115
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
1216

@@ -18,11 +22,15 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
1822

1923
// import Echo from 'laravel-echo';
2024

21-
// window.Pusher = require('pusher-js');
25+
// import Pusher from 'pusher-js';
26+
// window.Pusher = Pusher;
2227

2328
// window.Echo = new Echo({
2429
// broadcaster: 'pusher',
25-
// key: process.env.MIX_PUSHER_APP_KEY,
26-
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
27-
// forceTLS: true
30+
// key: import.meta.env.VITE_PUSHER_APP_KEY,
31+
// wsHost: import.meta.env.VITE_PUSHER_HOST ?? `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
32+
// wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
33+
// wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
34+
// forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
35+
// enabledTransports: ['ws', 'wss'],
2836
// });
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div class="container">
3+
<div class="row justify-content-center">
4+
<div class="col-md-8">
5+
<div class="card">
6+
<div class="card-header">Example Component</div>
7+
8+
<div class="card-body">
9+
I'm an example component.
10+
</div>
11+
</div>
12+
</div>
13+
</div>
14+
</div>
15+
</template>
16+
17+
<script>
18+
export default {
19+
mounted() {
20+
console.log('Component mounted.')
21+
}
22+
}
23+
</script>

resources/sass/_variables.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Body
2+
$body-bg: #f8fafc;
3+
4+
// Typography
5+
$font-family-sans-serif: 'Nunito', sans-serif;
6+
$font-size-base: 0.9rem;
7+
$line-height-base: 1.6;

resources/sass/app.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Fonts
2+
@import url('https://fonts.googleapis.com/css?family=Nunito');
3+
4+
// Variables
5+
@import 'variables';
6+
7+
// Bootstrap
8+
@import 'bootstrap/scss/bootstrap';

vite.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { defineConfig } from 'vite';
2+
import laravel from 'laravel-vite-plugin';
3+
import vue from '@vitejs/plugin-vue';
4+
5+
export default defineConfig({
6+
plugins: [
7+
laravel({
8+
input: [
9+
'resources/sass/app.scss',
10+
'resources/js/app.js',
11+
],
12+
refresh: true,
13+
}),
14+
vue({
15+
template: {
16+
transformAssetUrls: {
17+
base: null,
18+
includeAbsolute: false,
19+
},
20+
},
21+
}),
22+
],
23+
resolve: {
24+
alias: {
25+
vue: 'vue/dist/vue.esm-bundler.js',
26+
},
27+
},
28+
});

0 commit comments

Comments
 (0)