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

結果:

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

ts-loader-default_e3b0c44298fc1c14

raw-loaderの前後に入れてみts-loaderましたが、違いはありませんでした。

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

私もやってみました:

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

そして、それもうまくいきません。

トレースの解像度は次のとおりです。

======== 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. ========

これを typescript または javascript としてロードしようとするのはなぜですか? そうしないようにするにはどうすればよいですか?

4

0 に答える 0