Problem/Motivation

Since Sass 3.4 some of the generated CSS files contains a BOM flag to be compliant with CSS Syntax Module Level 3. The problem is that Drupal's CSS aggregator does not remove that flag. It that case, some CSS rules, often related to webfonts, are not loaded anymore.

Proposed resolution

An easy hack can be added in the config.rb file to remove the BOM automatically.

# Removes the BOM for UTF-8 stylesheets.
on_stylesheet_saved do |filename|
  css     = File.open(filename, 'r')
  content = css.read
  if "UTF-8" == content.encoding.name
    content.sub!("\xEF\xBB\xBF".force_encoding("UTF-8"), '')
    File.write(filename, content)
  end
end

Remaining tasks

Add this snippet to the base config.rb file.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

DuaelFr created an issue. See original summary.

duaelfr’s picture

Drupal 8 manages it in Core #1833356: CSS files encoded in UTF-8 with BOM break the design when enabling CSS aggregation
But while that's not backported to D7 we should have this little fix in our config.rb :)

avpaderno’s picture

Component: Feature Request » Code
Category: Feature request » Task