I'm new to vue/webpack and I can't find a proper way to use scss files in a project that use vue-routing.
here is the project structure:
/src
/routes
route1.vue
route1.js
route2.vue
route2.js
...
/scss
main.scss
mixins.scss
route1.scss
route2.scss
...
main.js
index.html
the code of route1.vue (and route2, except from the script src) is:
<template>
<div id="header">
<div class="title">{{title}}</div>
</div>
</template>
<script src="./route1.js"></script>
<style lang="scss">
@import "../scss/main";
</style>
the main.js manages the routing (as found on the tutorial)
When I run the project in dev mode by webpack, I've found that everytime I load a routing component, on the index page the tag style with all the contents of the main.scss is duplicated for each routing.
How can I avoid it?
Where should I put the scss import to include it on time only? Should I wrap the routing inside a top level component? (that seems quite complicated...)
Should I use a different approach? (I've used for a long time grunt/angular and maybe I'm trying to port a pattern that doesn't fit this tool...)
@importin one of.jsfiles likemain.js. Lastly add a link in yourindex.htmlto created style file.