2016-03-08 17 views
6

Kopiuj Wklej od kwestii TS-ładowarki jak to może być bardziej stosowne tutaj:Maszynopis -> Babel sourcemaps użyciu WebPACK

Jak przekazać sourcemaps maszynopisu do Babel więc koniec sourcemap punkt do oryginalnego pliku, a nie kompilowany maszynopis jeden?

Oto przykład z moich ustawień dev:

tsconfig.json:

{ 
    "compilerOptions": { 
    "target": "es6", 
    "jsx": "react", 
    "noImplicitAny": false, 
    "sourceMap": true 
    }, 
    "exclude": ["node_modules", "gulpfile.js", "webpack.config.js", "server.js"] 
} 

webpack.dev.js:

var path = require("path"); 
var webpack = require("webpack"); 

module.exports = { 
    devtool: "eval", 
    entry: [ 
    "webpack-hot-middleware/client", 
    "./src/app/index", 
    ], 
    output: { 
    path: path.join(__dirname, "build"), 
    filename: "app.js", 
    publicPath: "/static/" 
    }, 
    plugins: [ 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.NoErrorsPlugin(), 
    new webpack.ProvidePlugin({ 
     'window.fetch': 'exports?self.fetch!whatwg-fetch' 
    }) 
    ], 
    resolve: { 
    extensions: ['', '.ts', '.tsx', '.js'] 
    }, 
    module: { 
    noParse: [ 
     /\/sinon.js/ 
    ], 
    preLoaders: [{ 
     test: /\.ts(x?)$/, 
     loader: "tslint", 
     exclude: /node_modules/ 
    }], 
    loaders: [ 
     { 
     test: /\.tsx?$/, 
     loader: 'babel-loader!ts-loader', 
     exclude: /node_modules/, 
     include: path.join(__dirname, 'src') 
     } 
    ] 
    } 
}; 

Odpowiedz

0

Zobacz loaders: [ // note that babel-loader is configured to run after ts-loader { test: /\.ts(x?)$/, loader: 'babel-loader!ts-loader' } ]

2

Można użyć source-map-loader dla WebPack. Oto moja webpack.config.js:

module.exports = { 
    entry: "./app.ts", 
    output: { 
     filename: "./bundle.js", 
    }, 

    devtool: "source-map", 

    resolve: { 
     extensions: ["", ".webpack.js", ".web.js", ".ts", ".js"] 
    }, 

    module: { 
     loaders: [ 
      // ts -> ES6 -> babel -> ES5 
      { test: /\.tsx?$/, loaders: ["babel-loader", "ts-loader"] } 
     ], 

     preLoaders: [ 
      { test: /\.js$/, loader: "source-map-loader" } 
     ] 
    } 
}; 

I tsconfig.js:

{ 
    "compilerOptions": { 
     "target": "es6", 
     "sourceMap": true 
    }, 
    "exclude": [ 
     "node_modules" 
    ] 
} 

source in chrome devtools

Powiązane problemy