Skip to content

Installing cssbundling-rails on top of a new rails app breaks Stimulus, as well, some strange error in browser console #74

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

Closed
jasonfb opened this issue Jan 28, 2022 · 4 comments

Comments

@jasonfb
Copy link

jasonfb commented Jan 28, 2022

rails new TestApp

rails generate scaffold Posts

rails db:migrate

add <div data-controller="hello"></div> to anywhere

run rails s
Notice that the Stimulus controller works fine:

TestApp7 2022-01-28 11-20-29

Now install cssbundling the following way:

add gem 'cssbundling-rails' and uncomment gem 'sassc-rials'

bundle install

now run the cssbundling installer with rails css:install:bootstrap

You will now have the new bin/dev rails command on your machine (it is not there before you installed cssbundling). Whether rails is started with rails s or bin/dev rails, I get the same result, the Stimulus controller dies:

TestApp7 2022-01-28 11-23-02

There's also a strange console error, which I oddly I can't CLICK ON to see the line number. not sure why I can't click on it, usually Chrome lets me click into the line number where the error is and shows me the calling code, but in this error when I click it just does nothing.

TestApp7 2022-01-28 11-27-01

I'm not sure if the problem here is that cssbundling must be used with jsbundling and/or if jsbundling is used in conjunction with or as a replacement to importmap. I've spoken to several people on the chat boards and slack channel who are also confused by this so I would strongly urge some clarity around this.

I will re-attempt now with both cssbundling and jsbundling (this ticket is specific to ONLY cssbundling on top of rails new) At the very least if this is the wrong strategy I would strongly recommend documenting it clearly because right now I would still put this in the no-happiness category.

@jasonfb
Copy link
Author

jasonfb commented Jan 28, 2022

here's the recreation app: https://github.com/jasonfb/CBR-Issue75

This is the commit that breaks stimulus... what I really need to know I guess is what part of this commit is breaking stimulus:

https://github.com/jasonfb/CBR-Issue75/commit/116d4d1ab79606bdb768f33ea70a999475e6b041

@jasonfb jasonfb changed the title Installing css-bundling on top of a new rails app breaks Stimulus, as well, some strange error in browser console Installing cssbundling-rails on top of a new rails app breaks Stimulus, as well, some strange error in browser console Jan 28, 2022
@jasonfb
Copy link
Author

jasonfb commented Jan 28, 2022

OK so I experimented maybe with installing both cssbundling-rails and also jsbundling-rails but the situation does not improve.

The jsbundling-rails installer has many errors-- I think some because the cssbundling-rails did some of this already

https://gist.github.com/jasonfb/6c6a18f53b4fff37453f9d079c042f5e

either way, bin/dev rails now shows me the same page with Bootstrap styling but Stimulus does not load up

@dhh
Copy link
Member

dhh commented Jan 28, 2022

You can't switch between import map and jsbundler without several migration steps. This as designed. There are generated files that need to change.

@dhh dhh closed this as completed Jan 28, 2022
@jasonfb
Copy link
Author

jasonfb commented Feb 10, 2022

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

2 participants