1

I'm migrating a number of Projects from LESS to SCSS/SASS, all under Visual Studio 2013 with Web Essentials.

The only major problem is this: We have many files that use an absolute path like:

@import '/ui/crud/stuff.less';

Works great in LESS under Web Essentials. Then we go to use that same line in SCSS, and we get an error. We can fix it with a Relative Path:

@import '../../../../ui/crud.stuff.scss';

But:

  1. Wow that's ugly, but I'd cope with it if not for

  2. It's wrong, because in many cases these files are shared across projects, but not always in the same place in the hierarchy, meaning this path has to change project-to-project. So much for sharing the file in a submodule.

Digging at docs, I end up lost between 2 worlds. In pure SCSS land, I find confused bickering about modules. And in Web Essentials' docs SCSS/SASS isn't even listed on the website.

There's got to be a way to just get absolute paths working here.

Stuff I've Tried

@import '/ui/crud/stuff.less';
@import '~/ui/crud/stuff.less';
@import './ui/crud/stuff.less';
@import 'ui/crud/stuff.less';
@import 'crud/stuff.less';

All get the following error from the Web Essentials SCSS compiler.

Compilation Error occurred: file to import not found or unreadable

Chris Moschini
  • 36,764
  • 19
  • 160
  • 190
  • Can you not use @import "~/ui/crud.scss" ..? The tilde referring to the home directory - the web root of your project. – Stuart Mar 17 '16 at 20:20
  • @Stuart Good question, added a "Stuff I've Tried" section. Short answer: No that does not work. – Chris Moschini Mar 17 '16 at 20:36
  • Possible duplicate: http://stackoverflow.com/questions/6502313/sass-import-a-file-from-a-different-directory – cimmanon Mar 17 '16 at 20:37
  • @cimmanon That thread is asking about SASS in general, which has command-line tools and other options quite different from the Web Essentials approach, and the Accepted Answer is using a (very ugly) Relative Path, which I've specifically ruled out in my Question. I'm looking for an Absolute Path solution in Visual Studio with Web Essentials. I'm not opposed to resorting to additional tools, however. – Chris Moschini Mar 18 '16 at 15:16
  • Visual Studio Web Essentials doesn't compile using the sass command line tool under the hood? I don't know why you're "ruling out" relative paths, the accepted answer on the other question is just adding another search path for finding files to import. – cimmanon Mar 18 '16 at 15:22
  • @cimmanon Relative path issue is covered in my Question – Chris Moschini Mar 18 '16 at 17:23

0 Answers0