Skip to content

Commit

Permalink
Merge pull request #2660 from CachetHQ/setup-vue
Browse files Browse the repository at this point in the history
Setup Vue
  • Loading branch information
jbrooksuk committed Jul 26, 2017
2 parents 2b22caf + 3c55a47 commit 5e8e052
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@
"sortablejs": "^1.5.1",
"sweetalert2": "^6.6.6"
},
"private": true
"private": true,
"dependencies": {
"axios": "^0.16.2",
"vue": "^2.4.2"
}
}
25 changes: 24 additions & 1 deletion resources/assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
var Promise = require('promise')
/**
* Polyfill promises.
*/
const Promise = require('promise')

/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/

require('./bootstrap');

window.Vue = require('vue');

/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/

const app = new Vue({
el: '#app'
});
52 changes: 52 additions & 0 deletions resources/assets/js/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
window._ = require('lodash');

/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/

try {
window.$ = window.jQuery = require('jquery');

require('bootstrap-sass');
} catch (e) {}

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

window.axios = require('axios');

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

/**
* Next we will register the CSRF Token as a common header with Axios so that
* all outgoing HTTP requests automatically have it attached. This is just
* a simple convenience so we don't have to attach every token manually.
*/

let token = document.head.querySelector('meta[name="token"]');

if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: 'your-pusher-key'
// });

0 comments on commit 5e8e052

Please sign in to comment.