vendure-ecommerce/vendure

Plugin static assets not found

Opened this issue · 1 comments

Describe the bug
Hello,
I have a custom plugin where I use setBranding to change images / favicon following the docs here

@VendurePlugin({
  imports: [PluginCommonModule],
  providers: [
    { provide: IZAR_PLUGIN_OPTIONS, useFactory: () => IzarPlugin.options },
  ],
  configuration: (config) => {
    return config;
  },
  compatibility: "^2.0.0",
})
export class IzarPlugin {
  static options: PluginInitOptions;

  static init(options: PluginInitOptions): Type<IzarPlugin> {
    this.options = options;
    return IzarPlugin;
  }

  static ui: AdminUiExtension = {
    id: "izar-ui",
    extensionPath: path.join(__dirname, "ui"),
    routes: [{ route: "izar", filePath: "routes.ts" }],
    providers: ["providers.ts"],
    staticAssets: setBranding({
      smallLogoPath: path.join(__dirname, "images/izar-logo.png"),
      largeLogoPath: path.join(__dirname, "images/izar-logo.png"),
      faviconPath: path.join(__dirname, "images/favicon.ico"),
    }).staticAssets,
  };
}

I use the plugin as follows:

AdminUiPlugin.init({
    route: "admin",
    port: 3002,
    adminUiConfig: {
      apiPort: 3000,
      brand: "Izar",
      hideVendureBranding: false,
      hideVersion: true,
    },
    app: compileUiExtensions({
      outputPath: path.join(__dirname, "../admin-ui"),
      extensions: [
        IzarPlugin.ui,
      ],
    }),
  }),

After building npm run build and running npm run start:server I get this error:

Error: ENOENT: no such file or directory, lstat '.../dist/plugins/izar/images/izar-logo.png'

I can see that the images were copied to admin-ui folder under admin-ui/static-assets however the plugin in the dist folder expects the assets to be on the same folder because of path.join(__dirname, "images/izar-logo.png") I guess.

I'm not sure if this is a bug and the plugin system should be updating the image path or I should change the image path?

I'd appreciate if someone could point me to a workaround.

Thanks for the support ❤️

Expected behavior
Plugin assets are copied and paths are updated on build.

Environment (please complete the following information):

  • @vendure/core version: 2.2.7
  • Nodejs version: 20
  • Database (mysql/postgres etc): postgres

Getting same issue

@yazfield can you please share how you fixed it?

Error: ENOENT: no such file or directory, lstat '/usr/src/app/dist/plugins/services/ui'

the path should be this /usr/src/app/admin-ui/src/extensions/services