Which files can you override from a plugin?

AI-generated summary

In a discussion about overriding files from a plugin in Discourse, eatcodetravel asks whether files in the components directory can be overridden, noting they’ve successfully overridden most other files. vinothkannans explains that components can be modified via the PluginApi, referencing an example and listing available methods. eatcodetravel follows up, asking if structural properties like tagName can be changed — vinothkannans confirms this is possible using api.modifyClass('component:site-header', { tagName: 'section' }), and encourages exploring the guides and existing plugins. eatcodetravel clarifies they’re seeking to understand if any files are restricted from being overridden. vinothkannans reassures that Discourse core imposes no restrictions on plugin capabilities. eatcodetravel concludes that overriding components files should work and will verify their implementation. The consensus is that while direct file overrides may vary, nearly all functionality can be altered through PluginApi, which is the recommended approach.

I’m creating a plugin that overrides a lot of files for a pretty much complex customization of Discourse. I was able to override most of the file except for the ones in the components directory. Is this expected?, is so, which files you can override and which files you can’t?

Thanks!

You can modify components easily via PluginApi like below example

https://github.com/discourse/discourse/blob/master/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6#L8-L13

You can modify almost any file in one way or the other. PluginApi methods are better and recommended.

What about changing the tagName? or other things that are not in a method? is it possible too?

Yes. It is simple as

api.modifyClass('component:site-header', {
  tagName: 'section'
});

Anyway I recommending you to play around with the code before asking :wink:. And explore the guides, existing code, and plugins.

Cool, this is an alternative approach, but I want to know if there’s a restriction on the files you can override from a plugin?

No. Discourse core won’t restrict any plugin abilities.

Ok cool, so overriding files from the components directory should work. I’ll double check then

Thanks!