Proper way of adding CSS file in Vue.js Application
- Install sass
npm install sass-loader --save-dev
Create new
css
directory under yoursrc/assets
directoryCreate a
styles.scss
file in the newcss
directoryAdd the following line of code to your
main.js
file
import '../src/assets/css/styles.css';
In the styles.scss
file you can import multiple css files.
@import '~bootstrap/scss/bootstrap.min.css';
@import './common.css';
You can also write regular CSS properties like this in the same file
body {
background: gray;
}
div {
font-weight: bold;
}
- Restart your dev server
npm run serve