It would be great if I could convert LESS to CSS with a single command. http://lesscss.org/
EDIT: Looks like there is a simple windows command line app http://www.dotlesscss.org/. See documentation. So making a plugin should be very simple.
It would be great if I could convert LESS to CSS with a single command. http://lesscss.org/
EDIT: Looks like there is a simple windows command line app http://www.dotlesscss.org/. See documentation. So making a plugin should be very simple.
For a quick solution for ST1.4 take a look at this thread Command to run cmd script on file.
For ST2 not implemented but you can vote for it at the link at the bottom of the thread.
You could probably create a build system for this as well.
Looks like there is a windows commandline app for making a plugin should be easy http://www.dotlesscss.org/
My first plugin - Iâll add it to github @atomi when time permits.
Also, this is my first time playing with python.
Comments welcomed.
import sublime, sublime_plugin, subprocess, os
class CompileLessOnSave(sublime_plugin.EventListener):
def on_post_save(self, view):
if not view.scope_name(0).strip().endswith('source.css.less'):
return
if os.name == "nt":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(('dotless.Compiler.exe','-m',view.file_name()),
stdin=subprocess.PIPE, stdout=subprocess.PIPE, startupinfo=startupinfo)
print('Compiled ' + view.file_name())
Thanks to adzenith btw and Default/exec.py
I get this error
Reloading plugin C:\Users\robin\AppData\Roaming\Sublime Text 2\Packages\Less\SaveToCSS.py
Traceback (most recent call last):
File ".\sublime_plugin.py", line 29, in reload_plugin
File ".\SaveToCSS.py", line 6
if os.name == "nt":
^
IndentationError: unindent does not match any outer indentation level
[quote=âfirefusionâ]I get this error
Reloading plugin C:\Users\robin\AppData\Roaming\Sublime Text 2\Packages\Less\SaveToCSS.py
Traceback (most recent call last):
File ".\sublime_plugin.py", line 29, in reload_plugin
File ".\SaveToCSS.py", line 6
if os.name == "nt":
^
IndentationError: unindent does not match any outer indentation level
[/quote]
Change this line:
if not view.scope_name(0).strip().endswith('source.css.less'):
to this:
if not view.scope_name(0).strip().endswith('source.css.less'):
In python indentation is important. The two ifs have to line up.
Thanks for your help. Ok, now I get this error after saving the changeâŚ
Traceback (most recent call last):
File ".\sublime_plugin.py", line 29, in reload_plugin
File ".\CompileLessOnSave.py", line 1, in <module>
class CompileLessOnSave(sublime_plugin.EventListener):
NameError: name 'sublime_plugin' is not defined
It doesnât output a css file on save.
I have dotless.Compiler.exe set in the system path as it does work.
Iâm sorry I forgot to copy over the imports
import sublime, sublime_plugin, subprocess, os
class CompileLessOnSave(sublime_plugin.EventListener):
...
Great! That works
Anyway I could get âsheetsheet.css.lessâ to compile to the name âsheetsheet.cssâ and not âsheetsheet.css.cssâ?
Well yeah, you donât need to name your file blah.css.less it will work with the file name blah.less just the same.
True. I had them set to that as ZenCoding on worked if you have .css in the filename but with the new sublime-completions formatt i donât need zen for css anymore. Great plugin. Thanks
Thanks. It was totally your idea.
I hadnât even heard of dotless.Compiler before this post.
Cheers.
Iâm finding this crashes dotless quite a bit on big less files or if there is an error in the file. Where as dotless always works in the cmd. Do you think there is some memory limit for apps run through sublime?
The plugin is really basic. A lot of it is code that was directly copied from exec.py included in the Packages/Default folder.
I did crash dotless once, but that was because I was trying to import a file that didnât exist.
But, If youâd like you can post the file that is causing the crash and Iâll check it out.
Or email it to me if youâd rather do that (pm).
What are some good online tutorials or books to read to learn CSS? I want to re-design my website using a Photoshop template but I need to learn a little CSS first were is a good place to learn it online, or what are some good books?
affiliateelite ~ affiliateelite.com ~ adgooroo ~ adgooroo.com
Off topic a bit but anyone managed to get âGo to symbolâ working in .less files?
[quote="_druu"]Hereâs a little Build System I made (linux/mac)
https://gist.github.com/1347392[/quote]
I canât get this to work under the Automatic setting⌠and if i accidentally hit ctrl+b while itâs on my .css files⌠well⌠it tries to compile them, but since itâs already CSS it removes all whitespace >.<; not ideal.
To my understanding the âselectorâ of the sublime-build should be set to âsource.lessâ for it to pick up .less files under Automatic shouldnât it? why isnât this working and how do I make it work?
[quote=âMordofâ]
[quote="_druu"]Hereâs a little Build System I made (linux/mac)
https://gist.github.com/1347392[/quote]
I canât get this to work under the Automatic setting⌠and if i accidentally hit ctrl+b while itâs on my .css files⌠well⌠it tries to compile them, but since itâs already CSS it removes all whitespace >.<; not ideal.
To my understanding the âselectorâ of the sublime-build should be set to âsource.lessâ for it to pick up .less files under Automatic shouldnât it? why isnât this working and how do I make it work?[/quote]
You can check what the source selector is for the current view by using the keyboaord shortcut :
ctrl+shift+alt+p