Using webpack ^v2.2.1
, I would like to import a TypeScript module as text, in addition to importing the same module "normally".
I've figured that I probably should use the raw-loader. But it isn't working out.
Some example code:
import DemoComponent from './demo'
import demoCode from 'raw-loader!./demo'
TypeScript is screaming at me that something like
error TS2307: Cannot find module 'raw-loader!./demo'.
I'm 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