Install and setup Stimulus

This commit is contained in:
Andreas Nedbal 2022-10-02 22:09:01 +02:00
parent bf5d1c73d1
commit 58d8c827e0
4 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,8 @@
require('../styles/application.scss'); require('../styles/application.scss');
import { Application } from '@hotwired/stimulus';
import { definitionsFromContext } from '@hotwired/stimulus-webpack-helpers';
import start from 'retrospring/common'; import start from 'retrospring/common';
import initAnnouncements from 'retrospring/features/announcement'; import initAnnouncements from 'retrospring/features/announcement';
import initAnswerbox from 'retrospring/features/answerbox/index'; import initAnswerbox from 'retrospring/features/answerbox/index';
@ -26,4 +29,8 @@ document.addEventListener('DOMContentLoaded', initModeration);
document.addEventListener('DOMContentLoaded', initMemes); document.addEventListener('DOMContentLoaded', initMemes);
document.addEventListener('turbo:load', initAnnouncements); document.addEventListener('turbo:load', initAnnouncements);
document.addEventListener('turbo:load', initLocales); document.addEventListener('turbo:load', initLocales);
document.addEventListener('turbo:load', initFront); document.addEventListener('turbo:load', initFront);
window['Stimulus'] = Application.start();
const context = require.context('../retrospring/controllers', true, /\.ts$/);
window['Stimulus'].load(definitionsFromContext(context));

View File

@ -35,12 +35,12 @@ module.exports = function(api) {
exclude: ['transform-typeof-symbol'] exclude: ['transform-typeof-symbol']
} }
], ],
['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]
].filter(Boolean), ].filter(Boolean),
plugins: [ plugins: [
'babel-plugin-macros', 'babel-plugin-macros',
'@babel/plugin-syntax-dynamic-import', '@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node', isTestEnv && 'babel-plugin-dynamic-import-node',
["@babel/plugin-transform-typescript", { 'allExtensions': true, 'isTSX': true, 'allowDeclareFields': true }],
'@babel/plugin-transform-destructuring', '@babel/plugin-transform-destructuring',
[ [
'@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-class-properties',

View File

@ -5,6 +5,8 @@
}, },
"dependencies": { "dependencies": {
"@babel/preset-typescript": "^7.18.6", "@babel/preset-typescript": "^7.18.6",
"@hotwired/stimulus": "^3.1.0",
"@hotwired/stimulus-webpack-helpers": "^1.0.1",
"@hotwired/turbo-rails": "^7.1.3", "@hotwired/turbo-rails": "^7.1.3",
"@melloware/coloris": "^0.16.0", "@melloware/coloris": "^0.16.0",
"@rails/request.js": "^0.0.6", "@rails/request.js": "^0.0.6",

View File

@ -1086,6 +1086,16 @@
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.2.tgz#30aa825f11d438671d585bd44e7fd564535fc210" resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.2.tgz#30aa825f11d438671d585bd44e7fd564535fc210"
integrity sha512-82cpyJyKRoQoRi+14ibCeGPu0CwypgtBAdBhq1WfvagpCZNKqwXbKwXllYSMG91DhmG4jt9gN8eP6lGOtozuaw== integrity sha512-82cpyJyKRoQoRi+14ibCeGPu0CwypgtBAdBhq1WfvagpCZNKqwXbKwXllYSMG91DhmG4jt9gN8eP6lGOtozuaw==
"@hotwired/stimulus-webpack-helpers@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@hotwired/stimulus-webpack-helpers/-/stimulus-webpack-helpers-1.0.1.tgz#4cd74487adeca576c9865ac2b9fe5cb20cef16dd"
integrity sha512-wa/zupVG0eWxRYJjC1IiPBdt3Lruv0RqGN+/DTMmUWUyMAEB27KXmVY6a8YpUVTM7QwVuaLNGW4EqDgrS2upXQ==
"@hotwired/stimulus@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.1.0.tgz#20215251e5afe6e0a3787285181ba1bfc9097df0"
integrity sha512-iDMHUhiEJ1xFeicyHcZQQgBzhtk5mPR0QZO3L6wtqzMsJEk2TKECuCQTGKjm+KJTHVY0dKq1dOOAWvODjpd2Mg==
"@hotwired/turbo-rails@^7.1.0", "@hotwired/turbo-rails@^7.1.3": "@hotwired/turbo-rails@^7.1.0", "@hotwired/turbo-rails@^7.1.3":
version "7.1.3" version "7.1.3"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-7.1.3.tgz#a4e04ecb800a06e7f9aa6e298170fa4580b74216" resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-7.1.3.tgz#a4e04ecb800a06e7f9aa6e298170fa4580b74216"