Skip to main content

Vue: share the same bootstrap across multiple files

Javascript • Asked by CuamckuyKot

Hi, guys!

I'm tired to copy-paste the same piece across multiple files.

import Vue from 'vue/dist/vue.js'
import VueResource from 'vue-resource'
import TurbolinksAdapter from 'vue-turbolinks'
import vueFilter from 'vue-filter'
Vue.http.headers.common['X-CSRF-Token'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content')

        return {
            routes: Routes,
            current_user: gon.current_user,

Is there any trick to share the same piece of javascript across multiple js files to follow DRY.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.