This project is coded with Vue.
I want to import a sass file to a sub component. But the browser reported an error 'File to import not found or unreadable: ../assets/scss/global_css.scss'
I have tried to import 'global_css.scss' into the parent component and delete 'scoped' from < style >. This approach can be effective! But I`m afraid this will affect CSS styles among components.I hope to find a better solution.
I have tried to import 'global_css.scss' into < script > of the sub component.(That sounds unreliable, and so does the fact.)
This is the code used to import the 'global_css.scss'.
<style scoped lang="scss">
@import "../../assets/scss/global_css";
</style>
(PS.My experience is still shallow. If I have any fault, please forgive me.)
This problem has been solved with Uiosun`s help. He suggested modifying the code in the configuration file. The code as follows:
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass',{data:'@import "../assets/scss/global_css";'}), //Delete the code after the comma
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus'),
}
Corrected code:
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus'),
}
Success!