I'm using node-sass
directly from the command line (a Makefile, really) to build my CSS.
The scss files are in different directories and they don't refer to each other. What I'd want to have is sassify these files to a single CSS output that I can read in from the HTML - with working source maps.
This is the current command I have in the Makefile:
$(OUT_MAIN_CSS): $(SCSS) Makefile $(node-sass)
cat $(SCSS) > $(TMP_SCSS)
$(node-sass) --output-style compressed --source-map $(OUT_MAIN_CSS).map $(TMP_SCSS) $@
rm $(TMP_SCSS)
OUT_MAIN_CSS
is out/bundle.css
. SCSS
is a list of the input files. node-sass
is node_modules/.bin/node-sass
.
I'd like to have a one-liner and not need a temporary file. Also, I'd like my source map references (for debugging) to lead to the original files, not the temporary file.
node-sass [options] <input.scss> [output.css]
Here, node-sass
insists on having just a single input file. If I have two or more, the second one gets treated as output, and its contents overridden.
There are some options for an "input directory" and "output directory" but I don't want to constrain my build processes by such rather arbitrary restrictions (yes, eventually I shall bend...).
cat <input.scss> | node-sass [options] > output.css
This is more in line with the Unix mentality. Problem is twofold. My output file is in a subdirectory (out/bundle.css
), which confuses source map references since node-sass
has no idea of the output path.
There seems to be --source-map-root
for that but I didn't get it to work...
I'm clearly placing a square bolt in a round hole here, am I not? How would you do this?
Is the best way to simply have one ring.scss
in the root, to gather all the unrelated pieces together, and then sassify that?
Why not create a single main
Sass file, import all of your files into it, and compile the main
file with node-sass? This should result in a single file with correct sourcemaps.