0.1.1 • Published 7 years ago

mult-react-scripts v0.1.1

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
7 years ago

mult-react-scripts

自定义的react-scripts

若未安装create-react-app,先安装

npm install create-react-app -g

然后创建项目

create-react-app appname --scripts-version mult-react-scripts

使用示例见mult-react-scripts-example

主要差异

  1. 加入react-hot-loader3
    支持react组件的热更新

  2. 多入口
    兼容原项目结构,主要目的在于避免反复安装依赖,可以当做一个项目目录,而不是单应用 要使用多入口,需要在src和public目录下建相同的文件名项目,在启动时加入'-- app=appname'参数,示例如下:

  • npm start -- app=appname
  • npm run build -- app=appname
  • serve -s build/appname
  1. code-splitting(懒加载)
    使用lazy-load-react支持react组件的懒加载

  2. 第三方库按需分离
    需要在项目src下加入配置文件appconfig.js,参考示例配置

  3. 支持alias配置
    参考示例配置

详细差异与使用,请参考文章用create-react-app定制自己的react项目模板

一些问题

  1. 使用import()代码分离不支持chunk的重命名

  2. React Hot Loader 3 的使用及遗留问题

参考文章:

用create-react-app定制自己的react项目模板

react hot loader Migration to 3.0

react hot loader Known Limitations

React Hot Loader 3 beta 升级指南

webpack2 code-splitting-libraries

webpack2 Resolve

webpack2 Migrating from v1 to v2

This package includes scripts and configuration used by Create React App. Please refer to its documentation: