meteor-scss icon indicating copy to clipboard operation
meteor-scss copied to clipboard

Enable importing of css files

Open sdarnell opened this issue 8 years ago • 8 comments

I need to be able to include regular css files from npm packages, and as I understand it, both libsass and node_sass in other toolchains support this now. Also, from the code in this package it looks like that was the intention (css is one of the extensions that is considered if no extension is present).

However, css files don't appear in the allFiles map so any form of import other than a fully absolute path does not work. Maybe this changed in recent meteor releases (I'm using 1.5.1)? I even tried using the sccs-config.json but again, that only seems to work for css files if full absolute paths are specified.

So this change adds a step to look for css files in the filesystem after trying the normal way. I narrowed the check down to only consider files ending in .css to limit the risk of breaking something.

For future reference, the most useful/recent conclusions I found were in this SO question: https://stackoverflow.com/questions/7111610/import-regular-css-file-in-scss-file/30279590#30279590

sdarnell avatar Aug 11 '17 23:08 sdarnell

Hmmm, maybe it would be better to add css to the array here? https://github.com/fourseven/meteor-scss/blob/master/plugin/compile-scss.js#L11 Can't imagine a lot of people are using both sass and css with different compile plugins. Any thoughts?

sebakerckhof avatar Aug 16 '17 08:08 sebakerckhof

Possibly... I guess that might fix it too. However, my understanding is that meteor can only have one plugin handling each file type (extension), and when I changed my local package to handle css files too, I got:

   While determining active plugins:
   error: conflict: two packages included in fourseven:scss (meteor and fourseven:scss)
   are both trying to handle *.css

Whether meteor really needs to handle it or not is another matter, though I suspect there are some built in assumptions. There may also be some confusion given the fourseven:scss plugin accepts 'css' files and outputs 'css' files. Ouroboros?

sdarnell avatar Aug 16 '17 10:08 sdarnell

Ouroborus wouldn't apply here since Meteor doesn't chain build plugins. And it's not uncommon for a compiler to output the same extension as it works on (e.g. babel). But I wasn't aware Meteor processes .css by default.

I'll take a closer look but it'll only be for next week. Then I'll do a release with this and your other PR.

sebakerckhof avatar Aug 16 '17 11:08 sebakerckhof

OK, thanks, that's great.

sdarnell avatar Aug 16 '17 12:08 sdarnell

Any update, or further thoughts?

sdarnell avatar Sep 12 '17 21:09 sdarnell

+1 for this.

mitar avatar Jan 10 '18 11:01 mitar

I made a PR with CSS imports working with POSTCSS in this Meteor React boilerplate from @juliancwirko. If you're having trouble making it work, take a look. It has the SCSS preprocessor working along with the POSTCSS as well. https://github.com/juliancwirko/scotty

livimonte avatar Apr 09 '18 12:04 livimonte

I think this pull request can be closed, because you can include .css files without a problem in the latest version.

sebastian-ruiz avatar Aug 16 '21 17:08 sebastian-ruiz

Closed per the previous comment. Feel free to re-open if still an issue.

StorytellerCZ avatar Jan 31 '23 12:01 StorytellerCZ