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

Remove hello_controller.js from install #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This gem is automatically configured for applications made with Rails 7+ (unless
### Installing with installer

1. Add the `stimulus-rails` gem to your Gemfile: `gem 'stimulus-rails'`
2. Run `./bin/bundle install`.
2. Run `./bin/bundle install`
3. Run `./bin/rails stimulus:install`

The installer will automatically detect whether you're using an [import map](https://github.com/rails/importmap-rails) or [JavaScript bundler](https://github.com/rails/jsbundling-rails) to manage your application's JavaScript. If you're using an import map, the Stimulus dependencies will be pinned to the versions of the library included with this gem. If you're using Node, yarn will add the dependencies to your `package.json` file.
Expand All @@ -24,7 +24,7 @@ The installer amends your JavaScript entry point at `app/javascript/application.
Note that we recommend running the installer as described above. But the following is helpful if you encounter errors while running the installer (e.g., if there are conflicts with existing files) or if you just like doing stuff manually. Follow the instructions for import map *or* JavaScript bundler, depending on your setup.

1. Add the `stimulus-rails` gem to your Gemfile: `gem 'stimulus-rails'`
2. Run `./bin/bundle install`.
2. Run `./bin/bundle install`

#### With import map

Expand Down Expand Up @@ -65,16 +65,19 @@ pin_all_from "app/javascript/controllers", under: "controllers"

#### With JavaScript bundler

3. Create `app/javascript/controllers/index.js` and load your controllers.
3. Create `app/javascript/controllers/index.js` and load your controllers:

Make sure to change `HelloController` to an actual controller and repeat for every controller you have or use the command mentioned in the comments below:
```javascript
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName

import { application } from "./application"
```

You can also load you controllers manually like this:

```javascript
import HelloController from "./hello_controller"
application.register("hello", HelloController)
```
Expand Down
7 changes: 0 additions & 7 deletions lib/install/app/javascript/controllers/hello_controller.js

This file was deleted.

3 changes: 0 additions & 3 deletions lib/install/app/javascript/controllers/index_for_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@
// ./bin/rails generate stimulus controllerName

import { application } from "./application"

import HelloController from "./hello_controller"
application.register("hello", HelloController)
2 changes: 0 additions & 2 deletions lib/install/stimulus_with_bun.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"app/javascript/controllers/index.js"
copy_file "#{__dir__}/app/javascript/controllers/application.js",
"app/javascript/controllers/application.js"
copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js",
"app/javascript/controllers/hello_controller.js"

if (Rails.root.join("app/javascript/application.js")).exist?
say "Import Stimulus controllers"
Expand Down
2 changes: 0 additions & 2 deletions lib/install/stimulus_with_importmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"app/javascript/controllers/index.js"
copy_file "#{__dir__}/app/javascript/controllers/application.js",
"app/javascript/controllers/application.js"
copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js",
"app/javascript/controllers/hello_controller.js"

say "Import Stimulus controllers"
append_to_file "app/javascript/application.js", %(import "controllers"\n)
Expand Down
2 changes: 0 additions & 2 deletions lib/install/stimulus_with_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"app/javascript/controllers/index.js"
copy_file "#{__dir__}/app/javascript/controllers/application.js",
"app/javascript/controllers/application.js"
copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js",
"app/javascript/controllers/hello_controller.js"

if (Rails.root.join("app/javascript/application.js")).exist?
say "Import Stimulus controllers"
Expand Down