Commit ff603155 authored by shangbj's avatar shangbj

使用TypeScript语言

parent d5324409
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="app"></div>
<script src="./dist/bundle.js"></script>
</body>
</html>
\ No newline at end of file
import {show} from './show';
show('TS')
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "3-2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --mode production",
"dev": "webpack --mode development"
},
"author": "",
"license": "ISC",
"devDependencies": {
"awesome-typescript-loader": "^5.0.0",
"typescript": "^2.9.1",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.3"
}
}
export function show(content:string){
document.getElementById("app").innerText = 'hello,' +content;
}
\ No newline at end of file
{
"compilerOptions": {
"module": "common.js",
// 编译出的代码采用的模块规范
"target": "es5",
//编译出的代码采用ES的哪个版本
"sourceMap": true
// 输出的SourceMap方便调试
},
"exclude": [
// 不编译这些目录里的文件
"node_modules"
]
}
\ No newline at end of file
const path = require("path");
module.exports = {
entry:'./main',
output:{
filename:'bundle.js',
path:path.resolve(__dirname,'./dist'),
},
resolve:{
//先尝试ts,tsx 后缀的 TypeScript 源码文件
extensions:['.ts','.js']
},
module:{
rules:[
{
test:/\.ts$/,
loader:'awesome-typescript-loader'
}
]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment