Import regular CSS file in SCSS file?

后端 未结 13 1400
旧巷少年郎
旧巷少年郎 2020-11-22 06:19

Is there anyway to import a regular CSS file with Sass\'s @import command? While I\'m not using all of the SCSS syntax from sass, I do still enjoy it\'s combini

13条回答
  •  臣服心动
    2020-11-22 06:48

    I can confirm this works:

    class CSSImporter < Sass::Importers::Filesystem
      def extensions
        super.merge('css' => :scss)
      end
    end
    
    view_context = ActionView::Base.new
    css = Sass::Engine.new(
      template,
      syntax:     :scss,
      cache:      false,
      load_paths: Rails.application.assets.paths,
      read_cache: false,
      filesystem_importer: CSSImporter # Relevant option,
    
      sprockets:  {
        context:     view_context,
        environment: Rails.application.assets
      }
    ).render
    

    Credit to Chriss Epstein: https://github.com/sass/sass/issues/193

提交回复
热议问题