Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a source maps support? #25

Open
maxisoft-git opened this issue Mar 14, 2016 · 8 comments
Open

Is there a source maps support? #25

maxisoft-git opened this issue Mar 14, 2016 · 8 comments

Comments

@maxisoft-git
Copy link

whether it is possible to include support for the creation of source maps?

@Vasfed
Copy link
Owner

Vasfed commented Mar 15, 2016

With new csso itself having them now this should be possible. Will look into it

@maxisoft-git
Copy link
Author

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.

Vasfed added a commit that referenced this issue Mar 15, 2016
@Vasfed
Copy link
Owner

Vasfed commented Mar 15, 2016

Released 0.5.0 with support for sourcemaps, please test

@maxisoft-git
Copy link
Author

Я обновился до 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

@Vasfed
Copy link
Owner

Vasfed commented Mar 16, 2016

@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 }

@maxisoft-git
Copy link
Author

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 * /

@Vasfed
Copy link
Owner

Vasfed commented Mar 17, 2016

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

@maxisoft-git
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants