Remote Node.js typescript debugging in WebStorm

I am trying to debug a NodeJS backend written in TypeScript, and then translated into a single JavaScript file via webpack. Here is my webpack configuration.

var path = require('path')
var webpack = require('webpack')
var node_externals = require('webpack-node-externals')

module.exports = {
entry: './app.ts',
target: 'node',
externals: [node_externals()],
output: {
    path: path.resolve(__dirname),
    publicPath: '',
    filename: 'bin.js',
    devtoolModuleFilenameTemplate        : '[absolute-resource-path]',
    devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
},
module: {
    loaders: [
        {
            test: /\.tsx?$/, loader: 'ts-loader',
            exclude: /(node_modules|bower_components)/
        },
        {test: /\.json$/, loader: 'json'}
    ]
},
devtool: 'source-map',
resolve: {
    extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']
}
}

Source maps are generated correctly, and debugging works if the Node instance is local. The problem is that I run my Node instance in the docker container, so I have to debug it using remote debugging. And it just doesn't work (which is understandable because WebStorm has no idea about TypeScript files and all materials). The question is, can this work be done?

+4
source share

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


All Articles