Sass compile compressed in CLI - sass

sass input.scss:output.css
works well on my server, but the output is uncompressed.
Can I pass arguments to compress the css like the following?
sass input.scss:output.css =compressed
or sass input.scss:output.css minified
?
watch
is not supported on my server and there is no option to get it to work.
Instead, I have to manually compile the sass via the CLI statement on line 1 of this post
Thank you in advance!

You should be able to use the standard Ruby-style flags. Try this:
sass input.scss:output.css --style compressed

Related

Sass compilation using Compass on Cloud9?

I am trying to compile my Sass on the Cloud9 (http://c9.io) IDE. I have a Compass config.rb file, which I'd like to be adhered to.
The output of sass -h within the terminal states that a --compass option exists:
mikemike#x:~/workspace/resources/assets/sass (master) $ sass -h compass
Usage: sass [options] [INPUT] [OUTPUT]
Description:
Converts SCSS or Sass files to CSS.
Common Options:
-I, --load-path PATH Specify a Sass import path.
-r, --require LIB Require a Ruby library before running Sass.
--compass Make Compass imports available and load project configuration.
-t, --style NAME Output style. Can be nested (default), compact, compressed, or expanded.
-?, -h, --help Show this help message.
-v, --version Print the Sass version.
I'm unsure how to get this working. There is no additional information on it and simply running sass --compass or sass --compass config.rb just seems to put sass in interactive mode.
The command you just ran is giving you a hint as to how you're supposed to use it. It expects an input and an output. Since you're providing neither, it goes into interactive mode.
You can't specify the location of the config.rb, this is by design. Use the compass command instead (eg. compass watch).
sass --compass is intended to be a quick-and-dirty way to get access to the Compass libraries that don't require any configuration. If you want anything more complicated, you should use the compass executable.
https://github.com/sass/sass/issues/858

Why is this Gulp error?

Im following this tutorial to compile Sass with Gulp
https://www.youtube.com/watch?v=cg7lwX0u-U0
I think im doing the same as in the video but I get this error that I don't understand.
I don't want to compress it, I just want to compile all my .scss files to a single styles.css file, as I do with Compass.
You are using gulp-ruby-sass instead of the regular gulp-sass. gulp-ruby-sass does not use the gulp.src() command, instead you should give the path to it directly like this:
gulp.task('styles', function() {
sass('sass/_*.scss')
.pipe(gulp.dest('css/'));
});

How to convert directory SASS/SCSS to CSS via command line?

I tried:
sass-convert --from scss --to css --recursive app/assets/stylesheets temp
But this only converts css to SASS, and I want the other way around.
Then I looked at the sass command, but it doesn't look like I can pass it a directory.
To do a one-time Sass compile instead of a watch, you can do this from the command line:
sass --update scss:css
To have Sass import one file (usually a partial, with a _ starting the filename), you can do this inside a Sass file:
#import "_base.scss";
This way, Sass knows where you want the include to occur.
By default, Sass can't import an entire directory. The Sass Globbing gem, however, can. You can install it from the command line:
gem install sass-globbing
And then watch with it:
sass -r sass-globbing --watch sass_dir:css_dir
Note that globbing will import files alphabetically, so be sure your CSS will cascade appropriately if this occurs.
Use the sass command followed by the input file name and path, a colon (:) and the desired output file name and path. If the output file does not already exist Sass will generate it. For example,
sass sass/main.scss:css/main.css
However, this is a one-off command that would require being run every time you want to generate a new CSS file. A simpler and handier method is to use Sass's built-in --watch flag. This watches for changes to your Sass file and automatically runs the compile command each time you save changes.
sass --watch sass/main.scss:css/main.css
If you have multiple Sass files within a directory you can watch for changes to any file within that directory:
sass --watch sass:css
Sass also has four CSS output styles available: nested, expanded, compact and compressed. These can be used thus:
sass --watch sass:css --style compressed
Refer to the Sass documentation for more.
to that, simply go your project directory and do this :
sass --update sass-dir:assets/css
with sass-dir the directory containing your actual sass files and assets/css the desired output directory.
Hope this could help.
You can use compass to convert Sass files into CSS.
To initialize the config.rb, try:
compass init --syntax=sass --css-dir=css --javascripts-dir=js
Once you've the configuration file, try:
compass compile
or by specifying the file explicitly: compass compile sass/foo.scss.
To install it, try:
sudo gem update
sudo gem install sass compass
https://sass-lang.com/guide
you can use
sass --watch [input folder path]:[output folder path]
i tried running it in a new terminal and after that sass watches the folder and compiles upon any changes.
you can use this code
sass --watch file.sass:file.css
or
sass --watch folderSass:foldercss
if you want to create css.main you can use this code
sass --watch sass:css --style compressed

Sass command line option to force files with CSS extension as input

I've been using sass for quite some time however I was wondering if there is a way to force it to use files with a .css extension as input instead of the usual .scss.
The thing is I would like to use sass to perform minification on a rather old project which was written in pure CSS however stuff like this won't work until I change the extension of the file to .scss.
sass input.css output.css --style compressed
So basically what I am asking is if there is anything I could use to bypass the requirement sass is imposing on me to exclusively use files with .scss extension as input? Something like a command line option perhaps which I missed in the official documentation?
After some additional documentation book-worming and poking with the sass command line tool itself it seems I found the solution. All I needed to do is add the --scss argument to let sass know that no matter which file or extension I use it should interpret it as a SASS file. Since my CSS files are of course SASS compliant minification was performed without a trace of complaining.
sass --scss main.css main.min.css --style compressed
One little (in my opinion badly documented) command line argument and I waste the better part of the day to find it.

sass watch files in folder and minify, but control output filename

I know that I can watch a single file in a folder and have it compressed like so:
sass --watch HealthyArticles.scss:HealthyArticles.min.css --style compressed
What I'd like to be able to do is:
sass --watch *.scss:*.min.css --style compressed
The problem with this is that I get the error:
Errno::EINVAL: Invalid argument - *.scss
The main point is controlling the output filename. Is this possible with sass?
I think you're probably looking for Compass. All this stuff is just baked into Rails, so I'm not sure exactly how everything links together, but I believe if you're using SCSS without a framework around it, then Compass is what you're after.
Download from http://compass-style.org/ and run something like this:
gem install compass
$ compass create asd --bare --sass-dir "input_directory" --css-dir "output_directory"
You can set this in a config file:
output_style = :compressed
Alternatively, you could just run a script that does something like (this is Ruby):
files = Dir["/path/to/scss/folder/*.scss"].map do |file|
"#{file}:#{file.gsub(".scss", ".min.css")}"
end
`sass --watch #{files} --style compressed`

Resources