Save 36% for Black Friday! Learn more

All threads / Extend stimulus controller - base class not found
Ask A Question


You’re not receiving notifications from this thread.

Extend stimulus controller - base class not found

Thorsten Claus asked in Javascript

I want to extend the Stimulus controller to get some often used method in one place, like this:
import {Controller} from "@hotwired/stimulus"

export default class Base extends Controller {
defineSettings() {...}

Then I want to use this 'base' in my inherited controller, like a normal controller:

import Base from "./base.js"

export default class extends Base {
initialized() {...}


On my dev machine this works (after assets:precompile) but in production mode the 'base' class is not found:
"Error: Unable to resolve specifier 'base' imported from stream_controller..."

I am totally unsure if this possible and how to "correct" set my imports.

try to stackoverflow it, i saw the same issue on that

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 67,819+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.