Best way to have global css in Vuejs
I found the best way is to create a new file in the assets folder, I created as global.css
but you can name anything of your choice. Then, import this file global.css
file in the main.js
.
Note: Using this approach you can also create multiple files if you think the global.css is getting really large then simply import all those files in the main.js.
@\assets\global.css
/* move the buttons to the right */
.buttons-align-right {
justify-content: flex-end;
}
main.js
import Vue from 'vue'
import App from './App.vue'
import router from './routes'
Vue.config.productionTip = false
// Importing the global css file
import "@/assets/global.css"
new Vue({
router,
render: h => h(App)
}).$mount('#app')
Import css in your index.html, but if you're using webpack you can just import your stylesheets in your main js config and all your components will get the css.
As comments below suggested if using webpack adding this to main.js works:
import './assets/css/main.css';