Closed dschinkel closed 7 years ago
The @import
statement has to be used within CSS to work correctly. The best way to solve this is to link to your built CSS file with <link>
in the index.html
document.
<link rel="stylesheet" href="./src/css/main.css">
ah yea right. I tried doing but it hasn't worked, let me fiddle with it.
Just to clarify, postcss-import
works as a plugin in your PostCSS build step, not after. So given a file like this:
index.css
@import "./some-file.css";
@import "./some-other-file.css";
The files would be retrieved and built into the resulting CSS file in order. This is not to be confused with the native @import
statement found in the browser which fetches individual files with a network request at run time.
thanks. So if I want to import say another .sss into an .sss I have to tell it to look for .sss files using extensions? I don't see how to set that. Where and how would I tell it to look for .sss. What is the syntax or do I need a config file to specify that extension or can I add an option in my npm script? I'm using an npm script to run postcss btw..that outputs a css file based on my .sss file.
it's working didn't need to specify any extensions...
I'm not completely sure how to do this right.
I've got a script that uses sugarss to outpout a .css file from an .sss file. So after installing postcss-reasy-import (
npm i -D postcss-easy-import
), running postCSS using sugarCSS I get the following:Trying to now figure out how to use postcss-easy-import to import my .css file that sugarss generated into my inde.html:
index.html
...
I think I need to specify an extension? It says it defaults t css...so if I'm using sugarss but I'm trying to import a css file I assume I don't need to specify an extension since I'm importing a css file! right?
When I run this though I get the literal value @import "./src/css/main.css" printed to the page when I load my index.html page.
So stuck here.