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

generator-react-web-app

v0.2.0

Published

the scaffold of react web app

Downloads

3

Readme

generator-react-web-app

the scaffold of the react web app

使用方法

1. 安装脚手架工具

npm install -g yo

2. 安装生成器

npm install -g generator-react-web-app

使用-g进行全局安装,在以后每次新建项目时不需再次安装,可直接创建项目。

3. 创建项目

yo react-web-app

4. 目录结构

按上述步骤操作后,会得到如下目录结构:

├───package.json                  //包描述文件,包含基本模块的依赖
├───webpack.dev.config.js         //用于开发环境的webpack配置文件
├───webpack.prod.config.js        //用于生产环境的webpack配置文件
├───.gitignore                    //上传到github或gitlab时忽略不必要的文件
├───src/                          //源码的根目录
│   └───fonts/                    //放置自定义字体
│   └───images/                   //放置图片资源
│   └───javascripts/              //存放脚本的根目录
│     └───actions/                //放置redux的actions,该目录只在选择了redux选项时存在
│     └───components/             //放置组件
│     └───constants/              //放置常量
│     └───containers/             //放置容器组件,对于简单的项目,一般用于放置根组件
│     └───libs/                   //放置第三方库
│     └───reducers/               //放置redux的reducers,该目录只在选择了redux选项时存在
│     └───utils/                  //放置项目中的公共代码
│     └───main.js                 //入口脚本文件,对于简单的项目,一般用于绘制根组件
│   └───stylesheets/              //放置样式文件

5. 安装依赖

在项目根目录下执行:

npm install

6. 进入开发阶段(实时刷新)

npm run dev

在浏览器上打开地址localhost:8888(端口可以修改),即可在页面上看到Hello React字样,同时进入开发阶段,修改文件并保存后页面会实时刷新。

  1. HelloReact组件只用做demo演示,实际开发时需要通过删除HelloReact目录删除该demo组件。
  1. 有时运行该命令时会报如下错误:Error: listen EADDRINUSE 127.0.0.1:8888,遇到这种情况需要按照下面方法修改端口: 修改package.jso文件内scripts字段的dev命令,找到--port,将其后面的8888改为其他端口,如3000

7. 编译打包

npm run buld

编译后会生成dst目录,测试或发布时使用该目录即可。

8. 创建组件

在项目根目录下执行:

yo react-web-app:react-component

该命令会根据向导在src/javascripts/components/目录下创建相应组件。