How to import .scss.erb file into middleman4?

How to import .scss.erb file into Middleman 4?

I just upgraded from Middleman 3 to 4. I think this is my last question ...

I have an all.css.scss file that looks like this:

 @charset "utf-8"; @import "settings"; @import "imports"; @import "base"; @import "signature_pad" 

All files are imported except for import.

The difference with settings is that it _imports.scss.erb

Then, when I try to load all.css, I get the following:

 Error: File to import not found or unreadable: imports. Load paths: /Users/myMyserId/apps/projectName/source/assets/css /Users/myUserId/.rvm/gems/ruby-2.0.0-p451/gems/compass-core-1.0.3/stylesheets Compass::SpriteImporter /Users/myUserId/apps/projectName/source/assets/css /Users/myUserId/.rvm/gems/ruby-2.0.0-p451/gems/compass-core-1.0.3/stylesheets Compass::SpriteImporter /Users/myUserId/apps/projectName/source/assets/css /Users/myUserId/.rvm/gems/ruby-2.0.0-p451/gems/compass-core-1.0.3/stylesheets Compass::SpriteImporter on line 4 of /Users/myUserId/apps/projectName/source/assets/css/all.css.scss 

I think the problem is that erb does not process the file before making it .scss.

+6
source share
3 answers

Adding stars for this forum post received an import that worked as before.

In the Gemfile, add the asterisks and the rails-assets block using the gemfiles selected from step 1:

 # Gemfile gem 'middleman-sprockets', '4.0.0.rc.3' source 'https://rails-assets.org' do gem 'rails-assets-bootstrap-autohidingnavbar', '1.0.0' gem 'rails-assets-jquery', '2.1.1' gem 'rails-assets-slick.js', '1.5.7' end 

In your config.rb, add the following block to enable the asset pipeline and add RailsAssets gems to your download path:

 # config.rb # General configuration activate :sprockets if defined? RailsAssets RailsAssets.load_paths.each do |path| sprockets.append_path path end end 
+1
source

The difference with the settings is that it is _imports.scss.erb

It's your problem. Middleman alone does not touch with a leading underline. .Scss files are processed because SASS does the work.

The solution I am using (until I find another) is to create a second css file and just include it in my layout.

In your case, you can try to remove the underline; without a .css suffix, it should not be included in the output.

+6
source

Here is an example to make it work:

 // all.css.scss.erb <%= partial './_settings.scss' %> // rest of css… 

When setting up the file

  • named _settings.scss.erb
  • located as sibling file all.css.scss and
  • it may contain erb code! :)

However, I highly recommend learning the function of the external pipeline in Middleman 4. It is very powerful and allows you to better handle SASS / SCSS.

+2
source

All Articles