npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

egg-react-typescript-boilerplate

v5.1.2

Published

基于 egg + react + typescript + webpack 服务端渲染工程骨架项目

Downloads

17

Readme

egg-react-typescript-boilerplate

基于 Egg + React + TypeScript + Webpack 服务端渲染工程骨架

版本

  • Egg 版本: ^2.x.x
  • Node 版本: Node ^8.x.x+,
  • Webpack 版本: ^4.x.x
  • React 版本: ^16.0.0
  • TypeScript: ^3.0.0

文档

  • https://easyjs.cn/egg-react
  • https://www.yuque.com/easy-team/egg-react

特性

  • 支持 Egg Node 端代码和前端代码 TypeScript 编写和构建

  • 支持 Node 和 asyncData 方式获取数据进行渲染

  • 支持多页面(MPA) 和 单页面(SPA) 服务端渲染(SSR)和前端渲染(CSR)

  • 支持 AntD 按需加载和主题配置功能以及 MobX 应用

  • 支持 Webpack 时时编译和热更新, npm run dev 一键启动应用

  • 支持开发环境, 测试环境,正式环境 Webpack 编译

依赖

运行

安装依赖

npm install

本地启动应用

npm run dev

应用访问: http://127.0.0.1:7001

构建文件

  • TypeScript Egg 构建
npm run tsc
  • TypeScript 前端工程构建
npm run build

打包部署

  1. 先运行 npm run tscnpm run build 构建 TypeScript Egg 代码和 TypeScript 前端代码
  2. 项目代码和构建代码一起打包代码
  3. 应用部署后,通过 npm start 启动应用

开发

编写前端代码

添加 ${root}/app/web/page/demo.tsx 前端代码

'use strict';
import React, { Component } from 'react';
class Demo extends Component<any, any> {
  render() {
    const { title, article } = this.props;
    return <div>
      <h1 className="easy-article-detail-title">{title}</h1>
      <h3 className="easy-article-detail-title">{article.title}</h3>
      <div>{article.content}</div>
    </div>;
  }
}
export default Demo;

编写 Node 代码

添加 ${root}/app/controller/demo.ts Node 代码

import { Controller, Context } from 'egg';

export default class DemoController extends Controller {
  public async index(ctx: Context) {
    const title = 'Node 直接获取渲染数据';
    const article = await ctx.service.article.query({ id: Number(id) });
    await ctx.render('demo.js', { title, article });
  }
}

Egg 路由配置

添加 ${root}/app/router.ts Egg 路由配置

import { Application } from 'egg';
export default (app: Application) => {
  const { router, controller } = app;
  router.get('/demo', controller.demo.index);
};

Webpack 构建配置

添加 ${root}/webpack.config.js 新增页面 entry 配置

module.exports = {
  entry: {
    demo: 'app/web/page/demo.tsx',
  }
}

License

MIT