Using webpack ^v2.2.1 , I would like to import the TypeScript module as text, in addition to importing the same module normally.
I realized that I should probably use raw-loader . But it does not work.
Code example:
import DemoComponent from './demo' import demoCode from 'raw-loader!./demo'
TypeScript yells at me something like
error TS2307: Cannot find module 'raw-loader!./demo'.
I am using ts-loader .
Here is my webpack.config.js :
const { resolve } = require('path') const fail = require('webpack-fail-plugin') const config = { entry: './docs/index.ts', output: { filename: 'bundle.js', path: resolve(__dirname, 'docs-build') }, resolve: { extensions: [ '.ts', '.js' ] }, devtool: 'inline-source-map', module: { rules: [ { enforce: 'pre', test: /\.js$/, loader: 'source-map-loader' }, { test: /\.ts$/, loader: 'ts-loader' }, { test: /\.scss$/, use: [ 'style-loader', { loader: 'css-loader', options: { sourceMap: true } }, 'sass-loader' ] } ] }, plugins: [ fail ] } module.exports = config
source share