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

smart-easyteam-egg-react-spa-boilerplate

v1.0.1

Published

基于 easywebpack-react 和 egg-view-react-ssr 插件服务端渲染工程骨架项目

Downloads

22

Readme

smart-react-webpack-boilerplate

基于 Egg + React + Webpack 多页面服务端渲染同构工程骨架项目

文档

  • http://hubcarl.github.io/easywebpack/react/rule
  • https://zhuanlan.zhihu.com/easywebpack

特性

  • 基于 React 多页面服务端客户端同构实现

  • 支持 server 和 client 端代码修改, webpack时时编译和热更新, npm start 一键启动应用

  • 支持服务端渲染 render 和纯前端渲染 renderClient

  • 支持自动根据 jsx 文件构建 webpack entry 入口文件

  • easywebpack ^3.5.0 版本开始支持 webpack dll 自动化构建, 与多进程编译结合,构建速度减少 2/3

  • Node 8 版本的 async 和 await 特性, Controller 采用 class 方式编写

  • 支持国际化多语言

依赖

工程化

使用

安装cli

npm install easywebpack-cli -g

安装依赖

npm install
npm start

启动应用

npm start

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

npm start启动

配置说明

`config/config.local.js` 
const EasyWebpack = require('easywebpack-react');
exports.webpack = {
  webpackConfigList: EasyWebpack.getWebpackConfig()
};

构建会同时启动两个webpack构建服务, 客户端js构建(build/client), 服务端构建(build/server), 默认端口9000, webpackConfigList 端口依次递增.

项目构建

// 直接运行(编译文件全部在内存里面,本地开发使用)
npm start

// 编译文件到磁盘打包使用(发布正式环境)
npm run build 或者 easywebpack build prod

功能实现

多页面服务器渲染同构实现

编写jsx页面

在app/web/page 目录下面创建home目录, home.jsx, home.css文件.

  • home.jsx 编写界面逻辑
import React, { Component } from 'react';
import Header from 'component/layout/standard/header/header.jsx';
import List from 'component/home/list.jsx';
import './home.css';
export default class Home extends Component {
  componentDidMount() {
    console.log('----componentDidMount-----');
  }

  render() {
    return <div>
      <Header></Header>
      <div className="main">
        <div className="page-container page-component">
          <List list={this.props.list}></List>
        </div>
      </div>
    </div>;
  }
}

多页面后端实现

  • 创建controller文件home.js
exports.index = function* (ctx) {
  yield ctx.render('home/home.js', Model.getPage(1, 10));
};
  • 添加路由配置
app.get('/home', app.controller.home.home.index);

前端渲染

  • 创建controller的home.js 添加如下代码
exports.client = function* (ctx) {
  yield ctx.renderClient('home/home.js', Model.getPage(1, 10));
};
  • 添加路由配置
app.get('/client', app.controller.home.home.client);

License

MIT