Search code examples
csssassshopifyliquidcompass

use a different file extension instead of css while compiling with Compass


I am trying to compile a sass file like normal, but instead I want the output file to have the file extension ".scss.liquid" instead of the regular ".css".

For example: If I had the file "main.scss", I want the output upon compilation to be "main.scss.liquid", NOT "main.css".

I want this as i am using shopify.

Please note: I still expect the same output like when i compile normally with compass.

UPDATE:

It's worth mentioning that if you wanted to do this plain sass it would be done in the following way (I think):

sass input.scss output.scss.liquid

But how will this be done using compass


Solution

  • I managed to figure it out thanks to this: https://coderwall.com/p/5by4ww/compass-add-min-to-the-filename

    I just appended this to the end of the config.rb file:

    require 'fileutils'
    
    on_stylesheet_saved do |file|
      if File.exists?(file)
        filename = File.basename(file, File.extname(file))
        File.rename(file, "assets" + "/" + filename + ".scss.liquid")
      end
    end