TypeScript 构建支持

Node 启用 typescript 编译

  • egg-bin dev -r egg-ts-helper/register 实现开发

  • tsc -p tsconfig.json 编译

  • package.json 运行脚本

{
  "scripts": {
  "start": "egg-scripts start",
  "dev": "egg-bin dev -r egg-ts-helper/register",
  "debug": "egg-bin debug",
  "build": "easy build",
  "tsc": "tsc -p tsconfig.json",
}

前端启用 typescript 编译

// webpack.config.js
module.exports = {
  loaders:{
    typescript: true
  }
}

开启 tslint 校验

自动修复功能,tslint 默认启用, 自动修复默认禁用,可以通过如下方式开启

// webpack.config.js
module.exports = {
  loaders:{
    tslint:{
      options: {
        fix: true
      }
    }
  }
}

项目骨架

注意事项


Author: sky
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source sky !
 Previous
SEO实现 SEO实现
Egg + Vue SSR SEO 实现MVVM 服务端渲染相比前端渲染,支持SEO,更快的首屏渲染,相比传统的模板引擎,更好的组件化,前后端模板共用。在 Egg + Vue 的方案里面, HTML head 里面 meta 信息也作为 Vue 服务端渲染的一部分, 和普通的数据绑定没有什么差别。在实现上面, 考虑到页面有统一的 HTML, header, footer, body 骨架, 可以结合 Vue 的 slot 封装成一个统一的 layout 组件。一. layout...
2020-05-31 sky
Next 
从零开始 从零开始
从零开始搭建 Egg + Vue + Webpack 服务端渲染项目1. 初始化环境安装 Node LST (8.x.x) 环境: https://nodejs.org/zh-cn2. 初始化 egg 项目https://github.com/eggjs/egg-init/blob/maste...
2020-05-31 sky