react 项目模板

栏目: IOS · Android · 发布时间: 6年前

内容简介:根据自己常用的一些配置和需求,制定了一个项目模板基于 creat-react-app v2.x 搭建的项目模版以后会持续更新,不过频率不会很高

根据自己常用的一些配置和需求,制定了一个项目模板

基于 creat-react-app v2.x 搭建的项目模版

以后会持续更新,不过频率不会很高

项目名地址 gitee

技术栈

  1. react
  2. react-router
  3. mobx
  4. less(css module)

less-modules

使用 babel-plugin-react-css-modules .

这里需要注意一下, babel-plugin-react-css-modules 的配置项: generateScopedName ,其默认值是 [path]___[name]__[local]___[hash:base64:5] ;而对应的 css-loader 配置项 localIdentName 的默认值是 [hash:base64:5] .导致元素的类名和编译出来的 css 类名不匹配.

当前配置的 css-module 是如果直接以 .less 结尾则使用 css-module ,如果以 global.less 则使用原始的 less .

打包后的资源路径

默认打包后, index.html 文件中的资源路径都是以 / 开头的,这可能会导致引用错误.解决方法:

/config/paths.js

- envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
+ envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : './');

proxy

新版本的脚手架无法在 package.json 中使用对象形式的 proxy .需要安装 http-proxy-middleware 插件.然后配置 proxy

cd my-project
yarn add http-proxy-middleware -D
touch setupProxy.js

注意 /setupProxy.js 这个文件的路径在 /config/paths.js 中设置.按照插件说明配置完后,重启即可自动代理


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Art of Computer Programming, Volume 4,  Fascicle 3

The Art of Computer Programming, Volume 4, Fascicle 3

Donald E. Knuth / Addison-Wesley Professional / 2005-08-05 / USD 19.99

Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 4, Fascicle 3》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具