Skip to content

Commit 1447253

Browse files
committed
feature #65 Activating "debug" mode for Stimulus for dev builds (weaverryan)
This PR was merged into the main branch. Discussion ---------- Activating "debug" mode for Stimulus for dev builds Hi! Well... this was such an easy win, we should have done it awhile ago :). For a "dev" build, this activates Stimulus's debug mode, which outputs a lot of information to the log. Here is an example of a page with a single controller... and then after I activate an action on that controller: <img width="233" alt="Screen Shot 2022-04-19 at 10 09 53 AM" src="https://user-images.githubusercontent.com/121003/164023350-f0086b9b-afaa-47bb-b5f2-5e73e4f5da48.png"> When running `yarn encore production` (or `npm run encore production`), debug mode will be disabled. Heck, Weback is SO cool that, when building for production, the entire new `if` statement is omitted (i.e. this adds 0 extra bytes to production builds). Commits ------- 6618e29 Activating "debug" mode for Stimulus for dev builds
2 parents 78f17b3 + 6618e29 commit 1447253

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## 3.1.0
4+
5+
* Automatically enabled Stimulus's "debug" mode when doing a dev build. You will
6+
now, while developing, see debugging information in your browser's console log!
7+
See #65.
8+
39
## 3.0.0
410

511
Dropped support for `stimulus` 2.0, in favor of `@hotwired/stimulus` version 3.

dist/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ function identifierForContextKey(key) {
3131

3232
function startStimulusApp(context) {
3333
const application = Application.start();
34+
if (process.env.NODE_ENV === 'development') {
35+
application.debug = true;
36+
}
3437
if (context) {
3538
application.load(definitionsFromContext(context));
3639
}

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import symfonyControllers from './webpack/loader!@symfony/stimulus-bridge/contro
2020
export function startStimulusApp(context: any) {
2121
const application = Application.start();
2222

23+
if (process.env.NODE_ENV === 'development') {
24+
application.debug = true;
25+
}
26+
2327
if (context) {
2428
application.load(definitionsFromContext(context));
2529
}

0 commit comments

Comments
 (0)