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

Middleman 4.3 only supports SassC. Middleman-Sprockets needs to migrate to SassC as well #132

Open
tdreyno opened this issue Feb 7, 2019 · 20 comments

Comments

@tdreyno
Copy link
Member

tdreyno commented Feb 7, 2019

No description provided.

@Valerz
Copy link

Valerz commented Feb 13, 2019

Hi,

Do you think this ticket might be the cause of my issue?
I'm running middleman-sprockets ~> 4.1.0
In config:
If I de-active sprockets, my sass stylesheets work. But my my js (//= require) doesn't work.
If I activate sprockets my sass stylesheets break but my js (//= require) works.

@tdreyno
Copy link
Member Author

tdreyno commented Feb 14, 2019

I expect so. Which version of middleman are you using?

@Valerz
Copy link

Valerz commented Feb 14, 2019

running middleman 4.3.2

@tdreyno
Copy link
Member Author

tdreyno commented Feb 14, 2019

@Valerz try dropping down to 4.2.x for now

@Valerz
Copy link

Valerz commented Feb 17, 2019

@tdreyno
no luck on 4.2 either.

looks like a Windows os issue.
I've got a colleague on a iOS and works fine for him.

@abraham
Copy link

abraham commented Apr 19, 2019

I temporarily worked around this with adding gem 'sass' to Gemfile.

@komor72
Copy link

komor72 commented Apr 29, 2019

I stumbled upon this in my project, while trying (mostly successfuly) to upgrade MM 4.2.1 project using Ruby-Sass and Middleman-Sprockets to Mm 4.3.3 and SassC. Same results as @Valerz describes:
If I de-active sprockets, my sass stylesheets work. But my my js (//= require) doesn't work.
If I activate sprockets my sass stylesheets break (sassc CssSyntaxError: Unknown word) but my js (//= require) works.

Ruby version: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Middleman version: middleman (4.3.3)
OS version: macOS Mojave (10.14.4)

I understand that there is no solution yet, other than reverting back to my older MM 4.2.x (and Ruby-Sass)? My usage of Sprockets is very basic, only the js //= require, nothing else. I also use activate :minify_javascript in my config, but I guess it works without Sprockets, right?

By the way: why MM 3.3.x is supporting SassC only? Are the changes in the code breaking backwards compatibility with older Ruby-Sass?

@tdreyno
Copy link
Member Author

tdreyno commented Apr 29, 2019

Ruby-Sass is end of life'd. Everyone is having to switch to SassC. Synchronizing with Sprocket's migration is a headache. I'm not sure where this is now. It might be as simple as upgrading our copy of Sprockets... but that upgrade has always been painful as they assume Rails is their only API consumer.

Pinging @stevenosloan who had taken over maintenance of this repo.

@dagumak
Copy link

dagumak commented May 24, 2019

Ruby-Sass is end of life'd. Everyone is having to switch to SassC. Synchronizing with Sprocket's migration is a headache. I'm not sure where this is now. It might be as simple as upgrading our copy of Sprockets... but that upgrade has always been painful as they assume Rails is their only API consumer.

Pinging @stevenosloan who had taken over maintenance of this repo.

Is there any documentation for a migration path?

jonheslop added a commit to alphagov/pay-product-page that referenced this issue Jun 24, 2019
Middleman has updated to sassc but sprockets hasnt, so need to include
sass gem manually in the meantime

see this thread - middleman/middleman-sprockets#132
jonheslop added a commit to alphagov/product-page-example that referenced this issue Aug 5, 2019
As right now that’s required by middleman-sprockets - middleman/middleman-sprockets#132
freesteph added a commit to GovWifi/govwifi-product-page that referenced this issue Aug 13, 2019
The `sass` ruby gem is deprecated and `libsassc` (gem name: `sassc`)
is a much-faster, drop-in replacement.

Unfortunately `middleman-sprockets` isn't always happy with the new
gem[1] so include the old one as well in the bundle.

As per the code changes, point towards a standard and IE-specific
manifests, which in turn include the GOV.UK Frontend assets with the
correct ie-specific variables set in the latter case.

(re)compile-time greatly reduced.

[1]: middleman/middleman-sprockets#132
freesteph added a commit to GovWifi/govwifi-product-page that referenced this issue Aug 13, 2019
The `sass` ruby gem is deprecated and `libsassc` (gem name: `sassc`)
is a much-faster, drop-in replacement.

Unfortunately `middleman-sprockets` isn't always happy with the new
gem[1] so include the old one as well in the bundle.

As per the code changes, point towards a standard and IE-specific
manifests, which in turn include the GOV.UK Frontend assets with the
correct ie-specific variables set in the latter case.

(re)compile-time greatly reduced.

[1]: middleman/middleman-sprockets#132
freesteph added a commit to GovWifi/govwifi-product-page that referenced this issue Aug 19, 2019
The `sass` ruby gem is deprecated and `libsassc` (gem name: `sassc`)
is a much-faster, drop-in replacement.

Unfortunately `middleman-sprockets` isn't always happy with the new
gem[1] so include the old one as well in the bundle.

As per the code changes, point towards a standard and IE-specific
manifests, which in turn include the GOV.UK Frontend assets with the
correct ie-specific variables set in the latter case.

(re)compile-time greatly reduced.

[1]: middleman/middleman-sprockets#132
jonheslop added a commit to alphagov/product-page-example that referenced this issue Aug 19, 2019
As right now that’s required by middleman-sprockets - middleman/middleman-sprockets#132
freesteph added a commit to GovWifi/govwifi-product-page that referenced this issue Aug 20, 2019
The `sass` ruby gem is deprecated and `libsassc` (gem name: `sassc`)
is a much-faster, drop-in replacement.

Unfortunately `middleman-sprockets` isn't always happy with the new
gem[1] so include the old one as well in the bundle.

As per the code changes, point towards a standard and IE-specific
manifests, which in turn include the GOV.UK Frontend assets with the
correct ie-specific variables set in the latter case.

(re)compile-time greatly reduced.

[1]: middleman/middleman-sprockets#132
freesteph added a commit to alphagov/tech-docs-gem that referenced this issue Sep 3, 2019
we want the upgrade because it moves us away from the deprecated Ruby
`sass` (although still need to include it for compatibility
purposes[1]), gives us lots of speed and fixes a bug where a govuk
mixin cannot be resolved.

[1]: middleman/middleman-sprockets#132
jonheslop pushed a commit to alphagov/tech-docs-gem that referenced this issue Sep 3, 2019
we want the upgrade because it moves us away from the deprecated Ruby
`sass` (although still need to include it for compatibility
purposes[1]), gives us lots of speed and fixes a bug where a govuk
mixin cannot be resolved.

[1]: middleman/middleman-sprockets#132
jonheslop pushed a commit to alphagov/tech-docs-gem that referenced this issue Sep 3, 2019
we want the upgrade because it moves us away from the deprecated Ruby
`sass` (although still need to include it for compatibility
purposes[1]), gives us lots of speed and fixes a bug where a govuk
mixin cannot be resolved.

[1]: middleman/middleman-sprockets#132
@jclusso
Copy link

jclusso commented Oct 2, 2019

What is the status on this? With larger projects using ruby-sass is abysmally slow.

@tdreyno
Copy link
Member Author

tdreyno commented Oct 4, 2019

Current status is that this repo is unmaintained. Would happily merge any PR that brought it up to date with modern sprockets (and I assume sassc)

@jclusso
Copy link

jclusso commented Oct 4, 2019

@tdreyno is there an alternative to this for middleman? Just confused why it's not longer maintained.

@tdreyno
Copy link
Member Author

tdreyno commented Oct 4, 2019

The frontend world moved away from sprockets to stuff like Webpack. We deprecated support for sprockets in favor of a system which allows arbitrary javascript tooling when version 4 came out (2015): https://middlemanapp.com/advanced/asset-pipeline/

For a while, folks were maintaining this as they migrated to the new system. Seems like its been enough time that it has atrophied entirely. If you look at the Sprockets releases, maintained by the Rails team, it seems that dev has pretty much stopped: https://rubygems.org/gems/sprockets/versions

For modern sites, I don't think you need a pipeline or tooling at all. CSS has a module system (@import) and so does Javascript (ES modules) now.

On some sites, I run tsc --watch with the newer pipeline (https://middlemanapp.com/advanced/external-pipeline/) if I need TypeScript.

@jclusso
Copy link

jclusso commented Oct 5, 2019

Guess I gotta do some reading and get myself up to date. I use @import for my SASS. Main issue for me is coffeescript requires to be honest.

@tdreyno
Copy link
Member Author

tdreyno commented Oct 5, 2019

Gotcha. I believe Middleman code will compile your coffee script files (without sprockets) if you have the coffee script gem in your Gemfile. You'd need to find a way to replace the include/require parts with modern JS versions or a module/js compiler like webpack.

You could also downgrade to Middleman 4.2 which doesn't rely on the current version of Sass, so may work well with old sprockets.

@jclusso
Copy link

jclusso commented Oct 5, 2019 via email

freesteph added a commit to GovWifi/govwifi-product-page that referenced this issue Feb 20, 2020
middleman-sprockets is deprecated[1] so remove all of our terrible
hacks and stick with SASS import statements. Remove the hard
dependency on SASS as well since Middleman ships with it. Remove the
govuk_template dependency as we don't use it either.

This will also make the bundle smaller and faster (the node_modules
folder is +8M smaller).

[1]: middleman/middleman-sprockets#132 (comment)
@ojundt
Copy link

ojundt commented May 11, 2020

I was able to get it to work with middleman 4.3.6, middleman-sprockets 4.1.1 and sprockets 3.7.2 by adding this line in config.rb:

::Sprockets::Autoload::Sass = ::SassC

Ugly hack (you still get the warning 'consider using Sprockets 4.x to render with SassC') but it works until we find the time to refactor the asset pipeline.

@cabgfx
Copy link

cabgfx commented May 11, 2020

Thanks for sharing that, @ojundt !

chadlwilson added a commit to gocd/api.go.cd that referenced this issue Dec 24, 2021
Bump middleman-autoprefixer from 2.10.1 to 3.0.0

Sprockets needs to be locked at 3.7.2 due to middleman/middleman-sprockets#132 and middleman/middleman#2302

Just trying to bump dependencies as much as possible; not refactor/replace the asset pipeline just now.
chadlwilson added a commit to gocd/plugin-api.go.cd that referenced this issue Dec 24, 2021
Bump middleman-autoprefixer from 2.10.1 to 3.0.0

Sprockets needs to be locked at 3.7.2 due to middleman/middleman-sprockets#132 and middleman/middleman#2302

Just trying to bump dependencies as much as possible; not refactor/replace the asset pipeline just now.
chadlwilson added a commit to gocd/plugin-api.go.cd that referenced this issue Dec 24, 2021
Bump middleman-autoprefixer from 2.10.1 to 3.0.0

Sprockets needs to be locked at 3.7.2 due to middleman/middleman-sprockets#132 and middleman/middleman#2302

Just trying to bump dependencies as much as possible; not refactor/replace the asset pipeline just now.
@asecondwill
Copy link

Just leaving a comment so i can find this again. I couldnt get @ojundt fix to work. it said:

warning: already initialized constant Sprockets::Autoload::Sass
== Sprockets will render css with SassC

which it didnt. it just outputted the scss file unprocessed.

Getting a basic bootstrap demo working on a new install of middleman 4 today has been tricky. so giving up on sprockets for now.

@pomartel
Copy link

pomartel commented Jan 9, 2023

@asecondwill I gave up on Sprockets a fews weeks ago and just use an external pipeline instead with Dart Sass installed through Homebrew. Here is the relevant configuration from my config.rb file:

activate :external_pipeline,
  name: :sass,
  command: "/opt/homebrew/bin/sass --no-source-map #{ build? ? '' : '--watch' } --load-path=node_modules --load-path=source/images source/stylesheets/_application.scss:build/assets/application.css",
  source: "build/assets"

I have something similar to concatenate my JS files. Hope this helps!

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

10 participants