All threads / Vue: share the same bootstrap across multiple files
Ask A Question


You’re not receiving notifications from this thread.

Vue: share the same bootstrap across multiple files

CuamckuyKot asked in Javascript

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.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 70,078+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.