What is the equivalent of command "Compass watch" for LESS CSS pre-processor? - css

I was using SASS as CSS pre-processor for Drupal theme. Where in the command line if I use $ compass watch. It keep on watching the change in .scss file and apply to .css file.
Just I am trying Bootstrap theme and there I am using LESS CSS pre-processor, Where I have to use $ lessc less/style.less css/style.css every time to apply change.
What is the equivalent of $ compass watch for LESS.

You need to install less-watch-compiler:
npm install -g less-watch-compiler
Make sure you installed less globally:
npm install -g less
In Terminal, navigate to your working directory path and run the following command:
less-watch-compiler FOLDER_TO_WATCH FOLDER_TO_OUTPUT

Related

IntelliJ FileWatcher for SCSS not working

I would like to work in IntelliJ with SCSS files.
I see tutorial and I try to follow it. But for some reason this is not working for me.
WHAT I DID:
(I have a mac computer)
I download the node sass library : npm install -g sass
I add file watcher :
Scope : All Places
Program : usr/local/bin/node-sass
Arguments : --no-cache --update $FileName$:$FileNameWithoutExtension$.css
Output paths to refresh: $FileNameWithoutExtension$.css:$FileNameWithoutExtension$.css.map
But if I create .scss file and save it, it doesn't create any .css file.
Arguments you have specified are valid neither for Sass nor for node-sass.
For Sass (npm install -g sass) the most simple setup is:
For node-sass (npm install -g node-sass), it would be:

batch compiling SCSS files into CSS via windows command line

I am wondering, how to batch compile SCSS files via windows command line...in the older version the command 'sass --watch scssFolder:CSSFolder' will do the job but it seems obsolete in the newest version of the SASS.
The methods you used for the sass node module are deprecated in the latest version, so you have two (and more) options:
Option 1: using node-sass
This is the option with less effort. You already have Node.js installed (and npm), so you can install the node-sass compiler running npm install -g node-sass. After all the install is complete, you will be able to watch or compile an entire folder (or a single file).
node-sass input.scss output.css will compile a single file.
node-sass input/folder -o output/folder will compile a entire folder.
With the -w option you can watch a folder:
node-sass -w input/folder -o output/folder will watch a folder and compile the files to theoutput folder.
Just run node-sass --help for a complete list of options.
Option 2: using Ruby SASS
You need to install Ruby and the install the Sass Gem by running the following command line gem install sass. After all the install is complete, you will be able to watch or update (compile) an entire folder (or a single file).
update will compile a single file or multiple files in a folder (depending on the parameters). watch will do the same and after the initial compilation is completed it will watch the file or all the files in the specified folder, so everytime a change is detected on any of the target files, sass will compile the changed ones.
Both options have the same command line sintax:
sass --watch input/folder:output/folder
sass --watch input.scss:output.css
So, to compile all the files in a folder:
sass --update path/to/input/folder:path/to/output/folder
And to compile and then watch a folder:
sass --watch path/to/input/folder:path/to/output/folder
Just run sass --help for a complete list of options.
Hope it helps!
sass watch is not implemented for the moment in the darts version, to compile your .scss files you can use
sass filename.scss filename.css
If you want you can still use the ruby version but it will be obsolete soon.

sass error: No such file or directory

Sass is throwing an error on multiple projects on both of my computers when I try to compile the scss files to css. I'm using dart-sass. I'm typing the command in the terminal from the root of the projects and the file path is correct. I've tried both
sass --watch src/styles/scss:src/styles/css
and also just
sass src/styles/scss:src/styles/css
but the results are the same:
Error reading src/styles/scss:src/styles/css: no such file or directory.
As such I can't compile any of my style files.
filename is required to select directory
Try this sass --watch src/styles/scss/fileName.scss:src/styles/css
Okay, I figured out a solution if anyone else runs into this problem. You should uninstall dart sass from your computer(prefix this command with sudo if using mac):
npm uninstall sass -g
Then, install a stable version of ruby sass:
gem install sass
Now you should be able to run sass --watch src/styles/scss:src/styles/css and it will compile.
Note: If you were to do npm install sass that would install the latest version written in dart, which is what seems to have caused my problems.
In the terminal, I had to make my way to the file location and then run the command. Example:
Project Structure:
src
abc
prq
main.html
main.scss
When I launch the terminal, it defaults to src folder
PS C:\Users\src> sass --watch main.scss:main.css
Running command here will throw error:
Error reading main.scss: no such file or directory.
Now, browsing to prq directory & running command, will be successful.
PS C:\Users\src\abc\pqr> sass --watch main.scss:main.css
Compiled main.scss to main.css.
Sass is watching for changes. Press Ctrl-C to stop.

how to watch changes in whole directory/folder containing many sass files

How could I trace changes in whole directory containing many sass files ? I'm using the following command to watch changes in sass
file:
sass --watch style.scss:style.css
But how to watch changes in whole directory/folder containing many sass files.
Simply use the command sass --watch <input folder>:<output folder>, like this:
$ ls -l
css/ sass/
$ sass --watch sass:css
Where <input folder> contains the Sass files and <output folder> that hosts the generated CSS files.
Expanding the answer by piouPiouM a little:
Output files will be created with the same names as input files except ending with .css.
<input folder> and <output folder> can be the same.
Both folders can be the present working directory, so the following is valid:
$ sass --watch .:.
Go to you terminal and get to you folder then wrote:
sass --watch .
this will watch all sass files and convert to css files with the same name.
also you can do it in this way:
sass --watch ~/user/youUser/workspace/project/styles/
I hope this can help you.
I ended up doing this without using Grunt or Sass-watch:
npm install -g watch
watch "sass assets/app.scss assets/dist/app.css" assets/css
if you are in your current folder then do the following to watch it.
F:\sass tutorial>sass --watch ./:./
Just in case someone faces with this issue in 2018:
sass Website refers to Ruby Sass that is been deprecated.
and as now (May 2018) if you install dart sass via npm , it does not support --watch command
What to do:
you need to install node-sass globaly , like:
npm install node-sass -g
and then restart the command line , then use this code:
node-sass --watch scss/styles.scss css/styles.css
to compile your scass files to css.
basically node-sass supports --watch command and we use that to compile our scss codes to regular css files.
and just in case you get an error like this at the first time that you save your .scss file:
{
"status": 3,
"message": "File to read not found or unreadable: yourdirectory/scss/styles.scss",
"formatted": "Internal Error: File to read not found or unreadable: yourdirectory/scss/styles.scss\n"
}
what you need to do is save it again, it will work correctly!
According to the information, you can use the next command line:
sass --watch .
Source: http://sassbreak.com/watch-your-sass/#what-does---watch-do
You can create one sass file which includes the rest of the files, and then just watch this file.
Alternately, look into Grunt and the very good grunt-contrib-compass plugin
You can set sass to watch all the .scss files(for my case i got several .scss files in src/static folder) to compile, but before install it globally:
npm i -g sass
then go to the project folder and type command below:
sass --watch $(pwd)/src/static
also you can wrap it in npm script in package.json, like
"scripts": {
"sass:watch": "sass --watch $(pwd)/src/static"
}
and run it by this command:
npm run sass:watch

Sass not compiling in textmate

I'm trying to use SASS for the first time with textmate. I seem to have installed it correctly by following the instructions on the git page - https://github.com/MarioRicalde/SCSS.tmbundle
but I can't find any information on how I can now use it.
When I make a .sass file the new Sass syntax is highlighted but when I save it is not compiled. Am I missing something?
Make sure to open up Terminal and in the command line, navigate to your project folder and run this command:
sass --watch style.scss:style.css
Name your working file style.scss, and it will compile and generate and update the style.css file that you reference in your document head.
Also make sure you have installed the Sass gem within your project directory :)
gem install sass
UPDATE
The bundle is only for installing syntax highlighting in Textmate. Sass is a precompiler for CSS, so it generates CSS from what you write in Sass. This is done through the sass --watch command above in the command line.
Read more on how to use and install Sass.

Resources