stylesheets in highlight js are refused for being wrong MIME type

15 views Asked by At

I have an Angular 16 app that uses highlightjs. I technically installed the ngx-highlightjs library for Angular, but the stylesheets keep being refused by the browser because it says their MIME types are text/HTML. The code I use with highlight js is highlighted, however it seems to look the same no matter what I switch to as if it's defaulting to a particular set of rules. I have it setup in my main.ts file like this

export const appConfig: ApplicationConfig = {
  providers: [
    /* other stuff */
    {
      provide: HIGHLIGHT_OPTIONS,
      useValue: <HighlightOptions>{
        coreLibraryLoader: () => import('highlight.js/lib/core'),
        lineNumbersLoader: () => import('ngx-highlightjs/line-numbers'),
        languages: {
          xml: () => import('highlight.js/lib/languages/xml'),
          css: () => import('highlight.js/lib/languages/css')
        },
        themePath: '../node_modules/highlight.js/styles/a11y-dark.css'
      }
    }
  ]
};

I even added the stylesheet to the styles array in my angular.json file and I still get this error. Does anybody know how this can be fixed?

0

There are 0 answers