webpack - hur kan jag få ts-loader att inte försöka ladda .html-filer som TypeScript?


component.ts
import template from './template.html' 

resulterar i:

  TS2307: Cannot find module './template.html' or its corresponding type declarations.

ts-loader-default_e3b0c44298fc1c14

Jag försökte sätta raw-loader före och efter ts-loader, och det gjorde ingen skillnad.

loaders.unshift({
  test: /\.html$/,
  exclude: /node_modules/,
  use: 'raw-loader',
});

Jag försökte också göra:

component.ts
import template from '!!raw-loader!./template.html' 

Och det fungerar inte heller.

spårupplösning visar:

======== Resolving module './heading.html' from 'app/javascript/components/heading/heading.component.ts'. ========
Loading module as file / folder, candidate module location 'app/javascript/components/heading/heading.html', target file type 'TypeScript'.
File 'app/javascript/components/heading/heading.html.ts' does not exist.
File 'app/javascript/components/heading/heading.html.tsx' does not exist.
File 'app/javascript/components/heading/heading.html.d.ts' does not exist.
Directory 'app/javascript/components/heading/heading.html' does not exist, skipping all lookups in it.
Loading module as file / folder, candidate module location 'app/javascript/components/heading/heading.html', target file type 'JavaScript'.
File 'app/javascript/components/heading/heading.html.js' does not exist.
File 'app/javascript/components/heading/heading.html.jsx' does not exist.
Directory 'app/javascript/components/heading/heading.html' does not exist, skipping all lookups in it.
======== Module name './heading.html' was not resolved. ========

Varför försöker det ladda detta som TypeScript eller JavaScript? Hur kan jag säga åt det att inte göra det?