'Include 'normalize-scss' in Vue CLI 3
Just added the package normalize-scss to my new Vue project, but none of the styles are being applied... I've tried both:
@import 'normalize-scss' in my styles.scss
import 'normalize-scss' in my main.js page
Am I doing something wrong? The package is clearly there because the app runs, but it doesn't actually apply any css rules.
Solution 1:[1]
I figured it out. You need to put the normalize() after you import it, in your main.scss file. So:
@import 'normalize-scss';
@include normalize();
Solution 2:[2]
after installing it with npm import it at the top of main.js file:
import "normalize.css"
Solution 3:[3]
If you have a main/global scss file you already use:
- Add normalize.css (any of these) to your project:
yarn add normalize.css(or npm) - in your main.scss for example:
@import '~normalize.css';
Note the ~ for ambiguity as cli docs say: https://cli.vuejs.org/guide/css.html#referencing-assets
Solution 4:[4]
Not sure if this is the correct way to do this but, if you are using vue-templates maybe you can try to import the style doing this:
<style lang="scss">
@import 'src/assets/css/mycss_lib.css';
</style>
Also remember, do not use scoped in the style-tags. You also need, scss loader and node-sass to make this work.
Solution 5:[5]
npm install --save normalize-scss- In main scss file
@import "normalize-scss/sass/normalize/import-now";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tino |
| Solution 2 | |
| Solution 3 | trainoasis |
| Solution 4 | ValDaHus |
| Solution 5 | pavuk |
