0

So I'm trying to import my SCSS file with all vars and mixins definitions to all components I have. File name for defs is _defs.scss:

<style lang="scss"> @import "styles/defs"; some component styling </style> 

I also used alias in webpack to define where to look for styles folder:

resolve: { alias: { 'vue$': 'vue/dist/vue.esm.js', assets: path.resolve(__dirname, "src/assets/"), styles: path.resolve(__dirname, "src/styles/") } } 

But for some reason webpack still throws error telling he can't find the import file.
Where am I wrong?

Project Structure

Project Structure

9
  • Possible duplicate of How to preload variables in a component style Commented Aug 22, 2017 at 5:53
  • Question is not about ways of defining vars in global scope. Question is about why my paths are not working. Commented Aug 22, 2017 at 5:56
  • Hi, you mean you already imported sass-resources-loader? Commented Aug 22, 2017 at 5:59
  • Hello, I mean I don't use it in here. I ask why can't webpack find imported file, however I defined where to look for it in resolve.alias. Commented Aug 22, 2017 at 6:00
  • Okay, would you please share your project's structure? Commented Aug 22, 2017 at 6:08

2 Answers 2

1

Changing

@import "styles/defs"; 

to

@import "~styles/defs"; 

will solve the problem. See: explanation.

Sign up to request clarification or add additional context in comments.

Comments

0

I haven't use webpack in months, but can you check this:

https://webpack.github.io/docs/resolving.html, http://moduscreate.com/es6-es2015-import-no-relative-path-webpack/

1 Comment

Maybe I'm blind but it seems that everything is right. I've been breaking my head for some time already, so decided to write here in case I can't see some mistake I made.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.