csso-rails
csso-rails copied to clipboard
Is there a source maps support?
whether it is possible to include support for the creation of source maps?
With new csso itself having them now this should be possible. Will look into it
in the CSSO have this opportunity but csso-rails setup this is not possible to include the generation of files, there is only the option of code restructuring.
Released 0.5.0 with support for sourcemaps, please test
Я обновился до 0.5.0 внес изменения в свой файл config.rb (compass) вот он
#source map
sourcemap = true
# event task for auto-prefixer and notify saved your styles #Csso.optimize
on_stylesheet_saved do |file|
css = File.read(file)
map = file + '.map'
if File.exists?(map)
result = AutoprefixerRails.process(Csso.optimize_with_sourcemap(css, map),
from: file,
to: file,
map: { prev: File.read(map), inline: false })
File.open(file, 'w') { |io| io << result.css }
File.open(map, 'w') { |io| io << result.map }
else
File.open(file, 'w') { |io| io << Csso.optimize(AutoprefixerRails.process(css)) }
end
end
если использовать работу без source maps все работает как и работало, если сделать поддержку генерации maps то выдает ошибку
/usr/local/bin/compass compile /Users/admin/Sites/default/themes/devkit/scss
write /Users/admin/Sites/default/themes/devkit/assets/css/bootstrap.css
You're using ExecJS::ExternalRuntime, did you forget to add therubyracer or other execjs runtime to gemfile?
ExecJS::RuntimeError on line ["23106"] of Input.error ((execjs): CssSyntaxError: /Users/admin/Sites/default/themes/devkit/assets/css/bootstrap.css:7:91700: Missed semicolon
/*! normalize.css commit fe56763 | MIT License | github.com/necolas/normalize.css */
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body
@maxicms optimize_with_sourcemap(input_css, input_file_name_to_put_in_map)
returns array [css, map]
, the error you're getting is from autoprefixer (because it is being fed with invalid input).
Also it does not combine source maps in standalone, only via sprockets 4 (yep, have to run compress phase twice in current version)
So code will look like
#...
compressed_css,compressed_map = Csso.optimize_with_sourcemap(css, file)
combined_map = ... # here combine map from File.read(map) and compressed_map
result = AutoprefixerRails.process(compressed_css,
from: file,
to: file,
map: { prev: combined_map, inline: false })
File.open(file, 'w') { |io| io << result.css }
File.open(map, 'w') { |io| io << result.map }
with return parameters understood thanks, but even if you disable AutoprefixerRails then the output is optimized file in which there is no line / * # sourceMappingURL = bootstrap.css.map * /
Csso handles css as strings, it has no way of knowing what the url is going to be, you have to add that line yourself
very strange, as triggered by csso gulp or grunt work normally and processed at the end of a link to the css file. And in the css source code that compiles it also has a compass.