I am trying to import Material SCSS only for my Admin component.
This works fine when developing locally, but once I deploy my site to Firebase hosting, the Material styles get applied to all of my SPA, including the Client side.
I have tried:
// Importing the SCSS files within the Admin component ID
#admin {
@import "../../../../node_modules/vue-material/dist/vue-material.min.css";
@import "../../../../node_modules/vue-material/dist/theme/default.css";
}
then
// Importing the SCSS files within the Admin component CLASS
.admin {
@import "../../../../node_modules/vue-material/dist/vue-material.min.css";
@import "../../../../node_modules/vue-material/dist/theme/default.css";
}
then I tried it within the component itself
// Importing the SCSS files within the Admin components beforeCreate lifecycle hook
beforeCreate() {
// Ensuring style files only get loaded if this component is used
import("vue-material/dist/vue-material.min.css")
import("vue-material/dist/theme/default.css")
},
and finally:
// Importing the SCSS files within the Admin components, which is only rendered if in the
// main App component its v-if is true.
<script>
.
.
.
import "vue-material/dist/vue-material.min.css"
import "vue-material/dist/theme/default.css"
.
.
I thought it might be because of some cache in the browser, however I have tried hard reloading Chrome and tried multiple different browsers, but the problem persist.
Furthermore, I have tried commenting out the CSS imports and re-deploying, this did work. So the problem is somewhere within the Admin
component that how it imports and loads the styles.
Also the weird thing is that I have added a console log in the created
hook of the component, just to check if it gets created even if it shouldnt, and it doesnt. So I have no idea how the styles are getting in. I think they get mixed in with all the rest within the build process.
I am sure there is a simple solution to it, but I have run out of mine.