webpack系列之编译typescript

1.下载tsloader

npm install webpack typescript ts-loader awesome-typescript
-loader  --save-dev

配置webpack.config.js

module.exports={
    entry:{
        'app':'./src/app.ts'
    },
    output:{
        filename:'[name].bundle.js'
    },
    module:{
        rules:[
             {
                test:/\.tsx?$/,
                use:{
                    loader:'ts-loader'
                }
             }
        ]
    }
}

配置tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "allowJs": true

    },
    "include": [
        "./src/*"
    ],
     "exclude": [
         "./node_modules/"
     ]
}

你可能感兴趣的:(webpack)