# typescript初学 **Repository Path**: xhwtt/typescript-beginner ## Basic Information - **Project Name**: typescript初学 - **Description**: 记录学习typescript的过程 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-25 - **Last Updated**: 2021-10-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 使用webpack构建打包简单的ts文件 #### 构建项目 - npm init 项目初始化 - npm install --save-dev webpack webpack-cli 安装webpack - npm install --save-dev ts-loader 安装插件 ts转换js - 配置webpack.config.js 文件 ```javascript const path = require("path"); // node自带包 module.exports = { entry: "./assets/index.ts", // 打包对入口文件,期望打包对文件入口 output: { filename: "index.js", // 输出文件名称 path: path.resolve(__dirname, "dist"), //获取输出路径 }, mode: "development", // mode 可以不要,模式是生产坏境就是压缩好对,这里配置开发坏境方便看生成对代码 module: { rules: [ { test: /\.tsx?$/, use: "ts-loader", exclude: /node_modules/, }, ], }, resolve: { extensions: [".ts"], // 解析对文件格式 }, }; ```