-
-
Save hotoo/455009 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Js_css_compress () | |
let cwd = expand('<afile>:p:h') | |
let nam = expand('<afile>:t:r') | |
let ext = expand('<afile>:e') | |
if -1 == match(nam, "[\._]src$") | |
let minfname = nam.".min.".ext | |
else | |
let minfname = substitute(nam, "[\._\-]src$", "", "g").".".ext | |
endif | |
if ext == 'less' | |
if executable('lessc') | |
cal system( 'lessc '.cwd.'/'.nam.'.'.ext.' &') | |
endif | |
else | |
if filewritable(cwd.'/'.minfname) | |
if ext == 'js' && executable('closure-compiler') | |
cal system( 'closure-compiler --js '.cwd.'/'.nam.'.'.ext.' > '.cwd.'/'.minfname.' &') | |
elseif executable('yuicompressor') | |
cal system( 'yuicompressor '.cwd.'/'.nam.'.'.ext.' > '.cwd.'/'.minfname.' &') | |
endif | |
endif | |
endif | |
endfunction | |
autocmd FileWritePost,BufWritePost *.js :call Js_css_compress() | |
autocmd FileWritePost,BufWritePost *.css :call Js_css_compress() | |
autocmd FileWritePost,BufWritePost *.less :call Js_css_compress() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment