Webpack loader cannot find module

Edit 2: The problem is not in the web folder, but in typescript. Something with the declaration "* .md" as a module in a separate declaration file named .d.ts


Edit: It is confirmed that the problem is not related to the web package itself, since I received the following:

import txt from '../documents/test.md' export default { txt, } 

Attempting to load text files for client-side rendering.

I follow the instructions for raw-loader: https://webpack.js.org/loaders/raw-loader/

I also use typescript.

 import * as React from 'react' import txt from './file.txt' export default class HomePage extends React.Component<undefined, undefined> { render () { return <div>{txt}</div> } } 

My webpack configuration:

 module.exports = { entry: './src/index', output: { filename: 'bundle.js', path: __dirname + '/dist', }, devtool: 'source-map', devServer: { hot: true, }, resolve: { extensions: [ '.js', '.ts', '.tsx', '.web.js', '.webpack.js', ], }, module: { rules: [ { test: /\.tsx$/, loader: 'awesome-typescript-loader', }, { test: /\.js?$/, loader: 'source-map-loader', enforce: 'pre', }, { test: /\.txt$/, use: 'raw-loader' }, ], }, } 

But all I get is:

 ERROR in [at-loader] ./src/pages/Home.tsx:7:21 TS2307: Cannot find module './file.txt'. 

What am I missing? Thanks!

+1
source share

Source: https://habr.com/ru/post/1268946/


All Articles