-
Notifications
You must be signed in to change notification settings - Fork 0
Typescript
wangb edited this page Apr 8, 2018
·
10 revisions
npm init
npm i -D typescript webpack webpack-cli source-map-loader awesome-typescript-loader ts-loader tslint tslint-loader ts-node
npx tsc --init
This is my routine for create a ts project. I use webpack and awesome-typescript-loader to transpile and bundle the ts code into es code. The tslint and is used for lint my ts code. The ts-node
is used as a repl envrionment and run ts files directly.
Here is a simple webpack.config.js for ts:
const path = require('path')
const { CheckerPlugin } = require('awesome-typescript-loader')
module.exports = {
entry: './src/index.ts',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'app.bundle.js'
},
resolve: {
extensions: ['.js', 'json', '.jsx', '.ts', '.tsx']
},
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
loader: 'tslint-loader'
},
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}
]
},
plugins: [
new CheckerPlugin()
]
}