Since updating to Angular 13 when I import a markdown file containing images via markdown-loader, images are not shown.
Situation:
- I recently upgraded my app from Angular 12 to Angular 13
- I am using
@angular-builders/custom-webpackto configure webpack - nothing changed in my webpack config between the versions
- same version of
html-loaderandmarkdown-loaderin both
To isolate the issue, I created a new empty angular app with ng new on both ng12 and ng13, with following webpack config:
import { Configuration } from 'webpack';
export default {
module: {
rules: [
{
test: /\.md$/i,
use: [
{
loader: require.resolve('html-loader')
},
{loader: require.resolve('markdown-loader')}
],
}
],
}
} as Configuration;
markdown file with image:
Lemon the cat

using it as follows:
<div class="markdown" [innerHtml]="mdContent"></div>
import { Component } from '@angular/core';
import markdownFile from './markdown.md';
import {DomSanitizer} from "@angular/platform-browser";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor(private readonly sanitizer: DomSanitizer) {}
mdContent = this.sanitizer.bypassSecurityTrustHtml(markdownFile);
}
Results:
- The app created with Angular 12 shows the image which has been correctly extracted in the dist files.
- The app created with Angular 13 does not show the image, the image has not been extracted, and the link points to the local path, e.g.
<img src="file:///C:/dev/workspace/labs/markdown-images/src/app/lemon.jpg" alt="lemon">
Any idea at all about what could be causing this issue? Thank you.
Dependencies:
"dependencies": {
"@angular/animations": "~13.1.0",
"@angular/common": "~13.1.0",
"@angular/compiler": "~13.1.0",
"@angular/core": "~13.1.0",
"@angular/forms": "~13.1.0",
"@angular/platform-browser": "~13.1.0",
"@angular/platform-browser-dynamic": "~13.1.0",
"@angular/router": "~13.1.0",
"file-loader": "^6.2.0",
"html-loader": "^3.1.0",
"markdown-loader": "^8.0.0",
"rxjs": "~7.4.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^13.1.0",
"@angular-devkit/build-angular": "~13.1.2",
"@angular/cli": "~13.1.2",
"@angular/compiler-cli": "~13.1.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.5.2"
}
I tried to create a StackBlitz to reproduce the issue, but I can't even load MD files for some reason. https://stackblitz.com/edit/angular-13-markdown-loader