Replies: 5 comments
-
Hi Serhii! Try placing the export const controllers = import.meta.globEager('./components/ui/bentries/log/**/*_controller.js') |
Beta Was this translation helpful? Give feedback.
-
@ElMassimo thx for the fast response! But that don't work for me # config/vite.json
{
"all": {
"sourceCodeDir": "app",
"watchAdditionalPaths": []
},
"development": {
"autoBuild": true,
"publicOutputDir": "vite-dev",
"port": 3036
},
"test": {
"autoBuild": true,
"publicOutputDir": "vite-test",
"port": 3037
}
} //vite.config.ts
import { defineConfig } from 'vite'
import RubyPlugin from 'vite-plugin-ruby'
export default defineConfig({
plugins: [
RubyPlugin(),
],
}) #package.json
{
"name": "app",
"private": "true",
"type": "module",
"dependencies": {
"@hotwired/stimulus": "^3.0.1",
"@rails/actioncable": "^6.1.5",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.4",
"@tailwindcss/typography": "^0.5.9",
"birdeljs": "^3.3.4",
"esbuild": "^0.14.38",
"stimulus-vite-helpers": "^3.0.1",
"tailwindcss": "^3.3.3"
},
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"devDependencies": {
"vite": "^4.3.0",
"vite-plugin-ruby": "^3.2.0"
}
} // app/javascript/ui/bentries/log/index.js
import { Application } from '@hotwired/stimulus'
import { registerControllers } from 'stimulus-vite-helpers'
const application = Application.start()
application.debug = false
const controllers = import.meta.globEager('./components/ui/bentries/log/**/*_controller.js')
console.log("import.meta.globEager =>", controllers);
window.Stimulus = application
registerControllers(application, controllers) But this way gives me a list of imported modules const controllers = import.meta.globEager('../../../../components/ui/bentries/log/**/*_controller.js') ![]() |
Beta Was this translation helpful? Give feedback.
-
@ElMassimo maybe this can help somehow too |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@serhiijun To minimize confusion, instead of using relative imports it's preferable to use Import Aliases. For example, you can define an alias to the |
Beta Was this translation helpful? Give feedback.
-
As you can see,
window.Stimulus.controllers
is empty, is that a bug or just my issue?That works by the old way:
Beta Was this translation helpful? Give feedback.
All reactions