Instead of applying an output style when compiling my sass, is there a way of adding the output style (eg :compressed) into the file itself so that it's always compiled with that style?
As far as I know, this is not possible. I would suggest looking into using Compass to compile your sass instead of the default sass command line tool. With Compass, you create a config file (config.rb) that can include a line to specify your output style. Then, you just run the compass watch command, which automatically uses the output style that you specified in your config.
http://compass-style.org/
Related
I have a project with multiple directories with .sass files in each directory.
I want sass to watch all files and recomplie them if changes happen so sass --watch projectDirworks great but I also want to add a postfix to all compiled file for example myfile.sass will be myfile.post.css.
How do I do that?
If I cannot then is there a way to run batch sass commands from file?
I would suggest using a build tool such as gulp/grunt/webpack to watch your files and the compile your sass.
here is something that could get you started https://css-tricks.com/gulp-for-beginners/
I have set up Sass and created a project it was worked nicely but after restarting my computer, Now if I change, add or remove anything from my style.scss file it does not affect the style.css Before restarting it was functional and worked nicely.
Are you using command line to watch your SaSS file and compile your CSS? If so you may want to run your “—watch” command again.
this is my dir structure
css/
sprites/_sprite.scss
scss/important.scss
scss/file1.scss
...
scss/file5.scss
scss/file6.scss
scss/file7.scss
scss/file8.scss
scss/file9.scss
scss/file10.scss
I want to be able to use
compass watch
to monitor changes to scss/important.scss file ONLY.
I know about
compass watch scss/important.scss
But I want to achieve the same just using a config file conf.rb so I can use compass like that
compass watch
Why I want to do this? Because I want to run compass via Guard. I know that in Guard I can watch certain files but it doesn't help me as compass always rebuilds all the scss files regardless of what Guard watches.
The reason I want to build only one scss file is because I use compass to generate PNG sprite and it takes 5 seconds for each scss where that sprite is imported. Way too long to use Guard with LiveReload (11 x 5s !!!).
prefixing the other SCSS files with "_" is not an option.
I just want compass to watch one file without having to specify this file as a command line argument
OK, I have two ideas maybe can help you.
move your sass files to another directory except for main.scss, name that directory whatever you want, for example: includes. Then put additional_import_paths = 'path/to/includes', leave sass_dir as it used to be. Finally in your main.scss import other files. Now, compass knows the dependencies for main.scss but won't compile those files because they stay in an independent directory.
But there's a littler issue left: how to compile them in production environment? Well, compass allows us to specify environment variable like environment = :production (and its default value is :development). With this help, you can write your sass_dir as sass_dir = (environment == :production) ? 'path/includes/main' : ['path/includes/main', 'path/includes/others'], and execute command: compass compile -e production at the final stage.
Write a bash alias like: alias mycompass="compass watch scss/main.scss", and you know it. use mycompass for your own work, leave compass as it should be.
What I eventually did was:
I run
compass watch scss/important.scss
in one console and
guard -i
in another console. I set up Guard to watch on CSS file cachanges and do LiveReload. I removed compass from my guard configuration. Now it all works as I expected except I have to keep two terminals open.
Is it possible to use singularitygs in sass format rather than SCSS format?
Both singularitygs and breakpoint seems to come with only SCSS format files. If I manually convert the provided files to sass format, will that work?
I tried setting default format to sass in the config.rb file but that just seems to cause errors when starting to watch.
In Compass projects, you can interchange .sass and .scss files in the same project. Import them normally and you'll be OK.
That being said, as of this writing, both require custom Ruby functionality so in order to actually use either Breakpoint or Singularity, you need to be using them as Compass extensions as prescribed in their respective README files.
I used a switch --syntax sass to format a project in sass rather than SCSS:
compass create {project name} -r singularitygs --using singularitygs --syntax sass
SCSS and sass format can be mixed in different files but the watch function will not automatically compile the other format. For instance, if you set the default format to sass then any save to SCSS files will not be automatically processed.
The main reason I was getting the errors were from trying to install extension for compass.app. I am not sure what I am doing wrong but just copying singularitygs and breakpoint to the compass.app extension folder creates error on compass.app as well as the compass command line execution.
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.