All Projects → tsrot → React Zhihu

tsrot / React Zhihu

这是一个模仿知乎界面的简单React demo。这个React demo能让你从零开始学习React,并逐渐掌握React。它包括了一个项目从零到项目完成的整个过程。

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Zhihu

Phphub5
PHPHub Ver 5 is a Forum project Powered by Laravel 5.1, and it is also the project build up PHP & Laravel China community (此项目已弃用)
Stars: ✭ 1,971 (+800%)
Mutual labels:  gulp
Gulp Site Generator
A static site generator using Gulp
Stars: ✭ 183 (-16.44%)
Mutual labels:  gulp
Barekit
A bare minimum responsive framework
Stars: ✭ 201 (-8.22%)
Mutual labels:  gulp
Compile Hero
🔰Visual Studio Code Extension For Compiling Language
Stars: ✭ 169 (-22.83%)
Mutual labels:  gulp
Front End Tooling Recipes
Collection of pre-configured front-end tooling setups for common uses.
Stars: ✭ 176 (-19.63%)
Mutual labels:  gulp
100 Days Of Code Frontend
Curriculum for learning front-end development during #100DaysOfCode.
Stars: ✭ 2,419 (+1004.57%)
Mutual labels:  gulp
Hugo theme pickles
Modern, Simple and beautiful Hugo theme
Stars: ✭ 168 (-23.29%)
Mutual labels:  gulp
Miniprogram Ecommerce Open Source
果酱小店小程序端,基于原生小程序开发
Stars: ✭ 217 (-0.91%)
Mutual labels:  gulp
Jekyll Starter Tailwind
Jekyll starter styled with Tailwind CSS
Stars: ✭ 180 (-17.81%)
Mutual labels:  gulp
Angular2 Express Mongoose Gulp Node Typescript
AngularJS 2 (Updated to 4.2.0) Mean Stack application which uses Angular2, Gulp, Express, Node, MongoDB (Mongoose) with Repository Pattern Business Layer
Stars: ✭ 201 (-8.22%)
Mutual labels:  gulp
Generator Angular Webpack Es6
Yeoman generator for Angular projects using Webpack, ES6, SASS with some cool optional features. Feel free to contribute!
Stars: ✭ 172 (-21.46%)
Mutual labels:  gulp
Stellar
Stellar is completely based on the latest version of Bootstrap 4. Stellar Admin is designed to reflect the simplicity and svelte of the components and UI elements and coded to perfection with well-organized code.
Stars: ✭ 176 (-19.63%)
Mutual labels:  gulp
Gulp Webpack Starter
Gulp Webpack Starter - fast static website builder. The starter uses gulp toolkit and webpack bundler. Download to get an awesome development experience!
Stars: ✭ 199 (-9.13%)
Mutual labels:  gulp
Imall
基于Laravel5.2,Vue.js1.0的微信商城,用于熟悉 Laravel、Vuejs、Webpack、Gulp 的结合使用,已不维护及更新。(1MB单核基础服务器,浏览请耐心等待图片加载...)
Stars: ✭ 168 (-23.29%)
Mutual labels:  gulp
Ionic Starter Template
Reinventing the wheel, again! Sorry Ionic Team... but there are many newbies learning on Youtube!
Stars: ✭ 208 (-5.02%)
Mutual labels:  gulp
Maid
Markdown driven task runner.
Stars: ✭ 1,999 (+812.79%)
Mutual labels:  gulp
Tmt Workflow
A web developer workflow used by WeChat team based on Gulp, with cross-platform supported and solutions prepared.
Stars: ✭ 2,167 (+889.5%)
Mutual labels:  gulp
Material Admin
Free Material Admin Template
Stars: ✭ 219 (+0%)
Mutual labels:  gulp
Gulp Image
Optimize PNG, JPEG, GIF, SVG images with gulp task.
Stars: ✭ 213 (-2.74%)
Mutual labels:  gulp
Website
Techqueria is a nonprofit the serves the largest community of Latinx in Tech
Stars: ✭ 200 (-8.68%)
Mutual labels:  gulp

模仿知乎界面的一个简单React demo

博客地址:http://blog.xieliqun.com/2016/11/04/react-zhihu/

这是一个模仿知乎界面的简单React demo。这个React demo能让你从零开始学习React,并逐渐掌握React。它包括了一个项目从零到项目完成的整个过程。

项目运行

$ git clone https://github.com/tsrot/react-zhihu.git
$ cd react-zhihu

$ npm install

$ bower install

$ gulp server   //用浏览器打开 localhost:5000

搭建开发环境

初始化npm bower

npm init  //一直enter,默认就好

bower init //同上

安装必要的开发工具包

  • gulp :基于流的自动化构建工具
  • gulp-browserify :前端模块及依赖管理
  • gulp-concat :文件合并插件
  • gulp-react :JSX语法转化工具
  • gulp-connect :构建本地开发Web服务器
  • lodash :一个具有一致接口、模块化、高性能等特性的 JavaScript 工具库
  • reactify :React 编译器
npm install gulp gulp-browserify gulp-concat gulp-react gulp-connect lodash reactify --save-dev

安装生产环境依赖包

  • react :主要框架
  • react-dom :React的DOM操作类
  • bootstrap :bootstrap样式
npm install --save react react-dom

bower install --save bootstrap

写入gulp配置文件gulpfile.js

你可以在npm的网站上找到相应插件的gulp配置写法。我配置的gulpfile.js

开发

  • 切分相应的模块
  • 分清UI组件和容器组件
  • 学会如何在组件之间通信
  • 注意写作规范和开发细节

部署生产

请切换分支到 product 分支

修改gulpfile文件

//添加copy任务
gulp.task('copy',function(){
    gulp.src('./app/css/*')
    .pipe(gulp.dest('./dist/css'));

    gulp.src('./bower_components/**/*')
    .pipe(gulp.dest('./dist/libs'));

    gulp.src('./*.html')
    .pipe(gulp.dest('./dist'));
});

//生产服务器
gulp.task('connect-pro',function(){
    connect.server({
        root:'./dist',
        port:port,
        livereload:true,
    })
});

//添加build任务
gulp.task('build',['browserify','copy']);

//添加启动生产服务器任务
gulp.task('server-pro',['build','connect-pro','watch']);

修改index.html引用目录

<link rel="stylesheet" href="./libs/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="./css/index.css">

<script src="./js/main.js"></script>

使用gulp-gh-pages部署到github pages

下载gulp-gh-pages插件

npm install --save-dev gulp-gh-pages

在gulpfile文件中添加配置gulp-gh-pages代码

var ghPages = require('gulp-gh-pages');

gulp.task('deploy', function() {
  return gulp.src('./dist/**/*')
    .pipe(ghPages());
});

webpack + es6 (webpack分支)

1、手动删除bower_components,统一使用npm,这样有利于后面webpack的配置。 把bootstrap安装到node_modules:

$ npm install --save bootstrap

2、安装webpack-stream、vinyl-named、gulp-clean

$ npm install --save-dev webpack-stream vinyl-named gulp-clean

3、安装webpack plugin和webpack loader

$ npm install --save-dev html-webpack-plugin extract-text-webpack-plugin babel-core babel-loader babel-preset-es2015 babel-preset-react style-loader css-loader postcss-loader autoprefixer file-loader

4、配饰gulp和webpack

后续

将在分支中更新使用下列技术的版本

  • webpack + es6 : webpack分支
  • webpack + es6 + redux
  • webkack + es6 + redux + react-router
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].