1.安装nodejs
2.安装vs2013 或者vs2015,下载对应的typescript插件
3.创建项目
4.npm install -g tsd
5.tsd install react-global --save
tsd install node --save
6.npm install webpack
7.npm install babel-loader
8.vs2013编译ts项目,编译选项使用(也可以用webpack的ts-loader编译ts/tsx文件,编写tsconfig.json即可):
a.Module system: CommonJs
b.
ECMAScript version:
ECMAScript 5
c.不要合并文件,编译生成单独的js文件
9.webpack打包
编写webpack.config.js
var webpack = require('webpack');
var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js');
module.exports = {
entry: {
index: './js/app.js',
//entry2: './index/index2.js'
},
output: {
path: __dirname+'/js',
filename: '[name].js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}, {
test: /\.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader!jsx-loader?harmony'
}, {
test: /\.tsx?$/,
loader: "ts-loader",
}, {
test: /\.ts?$/,
loader: "ts-loader",
}]
},
externals:[
{'net': "require('net')"},
{"fs": "require('fs')"},
"Buffer"
],
plugins: [commonsPlugin]
};