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

Dynamic on the fly CSS generation #265

Open
pjmuller opened this issue Oct 3, 2023 · 0 comments
Open

Dynamic on the fly CSS generation #265

pjmuller opened this issue Oct 3, 2023 · 0 comments

Comments

@pjmuller
Copy link

pjmuller commented Oct 3, 2023

Hi,

I installed the following gems (in a rails 5.2.8.1 project on ruby 2.7.7)

gem 'sass-rails', '~> 5.0'
gem 'bootstrap', '~> 5.3.1'
gem 'sassc', '~> 2.4.0'

If I create a file like app/assets/stylesheets/foobar_bootstrap.scss
with content

$primary-color: blue;
@import "bootstrap";

it works perfect, however if I wish to generate styles on the fly in a controller action like

    sass_code = "$primary-color: blue; @import \"bootstrap\";"
    css_output = SassC::Engine.new(sass_code, syntax: :scss).render
    render plain: css_output, content_type: 'text/css'

I'm getting the error File to import not found or unreadable: bootstrap

any idea on how to point sassc to the right file?

Also I only want to overwrite the main colors, is there a lightweight way to only output all classes related to colours but leave the bulk file statically served?

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

1 participant