使用chrome调试我的typescript项目时,源映射不能按预期工作。它指向已编译的js文件而不是ts源文件。
我将"sourceMap": true
添加到tsconfig.json中,并在我的webpack.config.js中添加了devtools: 'inline-source-map'
。 Chrome告诉我state.ts中的第76行有错误,但state.ts chrome显示我是已编译的js文件。这是正常行为吗?或者我错过了什么?
tsconfig.json
{
"compileOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"allowJs": true
}
}
webpack.config.js
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './app/guides/identify_device/identify_device_guide.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: ['ts-loader'],
exclude: /node_modules/
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader']
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
modules: [
path.resolve('./app')
]
},
output: {
filename: 'src/bundle.js',
path: path.resolve(__dirname, 'dist')
},
devtool: 'inline-source-map',
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
server: {baseDir: ['./dist/']}
}),
new HtmlWebpackPlugin({
template: './app/index.html',
})
]
};
答案 0 :(得分:0)
最后,我使用**//onCreate**
ButterKnife.bind(this);
RxView.clicks(btn_range)
.switchMap(new Function<Object, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Object o) throws Exception {
return Observable.range(1,10);
}
})
.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
d.dispose();
}
@Override
public void onNext(Integer integer) {
Toast.makeText(MainActivity.this, integer+"", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Throwable e) {
Toast.makeText(MainActivity.this, e.getMessage()+"", Toast.LENGTH_SHORT).show();
}
@Override
public void onComplete() {
}
});
代替awasome-typescript-loader
并解决了这个问题。