Renamed internal.js pack file to admin.js (#11046)

This commit is contained in:
Nick Taylor 2020-10-23 17:57:39 -04:00 committed by GitHub
parent b6762fcc7b
commit d5dcda6af6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View file

@ -1,6 +1,9 @@
import { Application } from 'stimulus';
import { definitionsFromContext } from 'stimulus/webpack-helpers';
// This loads all the Stimulus controllers at the same time for the admin
// section of the application.
const application = Application.start();
const context = require.context('admin/controllers', true, /.js$/);
application.load(definitionsFromContext(context));

View file

@ -12,7 +12,7 @@
<title><%= controller_name.titleize %></title>
<!-- StimulusJS -->
<%= javascript_packs_with_chunks_tag "internal", defer: true %>
<%= javascript_packs_with_chunks_tag "admin", defer: true %>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>

View file

@ -33,8 +33,10 @@ Stimulus is a modest frontend framework; its primary purpose is manipulating
HTML. It does not provide templating features.
In the Forem application, [Webpacker](/frontend/webpacker/) is used to load
Stimulus controllers. Ideally, controllers serve as an abstraction for shared
functionality between views.
Stimulus controllers via the `app/javascript/packs/admin.js`
[pack file](https://github.com/rails/webpacker/blob/master/docs/folder-structure.md#packs-aka-webpack-entries).
Ideally, controllers serve as an abstraction for shared functionality between
views.
New controllers can be added in `/app/javascript/admin/controllers`. Unit tests
should exist for each controller in the adjacent