1

There must be a really simple solution I have tried everything.

App.vue file

<style lang="scss" scoped>
 @import 'src/assets/styles/_variables.scss'
 img {
    height: $height;
 }

</style> 

_variables.scss file

height: 27px;

Even if I move img { height: $height; } I still get an error. For the life of me I just want access to $height from an imported scss file. This must be so simple?

error seen in this screen shot: screenshot of error Raw Error:

ERROR in ./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"id":"data-v-06ade8f3","scoped":false,"hasInlineConfig":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue
Module build failed: 
  img {
  ^
      Invalid CSS after "img": expected 1 selector or at-rule, was "{"
      in /Applications/MAMP/htdocs/vuejs-portfolio/src/App.vue (line 63, column 4)

1 Answer 1

1

Try this way, it will solve your problem.

<style lang="scss" scoped>
 @import 'src/assets/styles/_variables.scss';
 img {
    height: $height;
 }
</style> 
Sign up to request clarification or add additional context in comments.

3 Comments

Ive added a screen shot to the original question
Please put a semicolon (;) at the end of @import 'src/assets/styles/_variables
gah a simple semicolon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.