首页 > Web开发 > 详细

React gulp、Browserify、Webpack实例

时间:2015-12-23 22:52:00      阅读:406      评论:0      收藏:0      [点我收藏+]

一、gulp

 1 var gulp = require(‘gulp‘);
 2 var react = require(‘gulp-react‘);
 3 
 4 gulp.task(‘jsx‘, function() {
 5     gulp.src(‘./app.jsx‘)
 6         .pipe(react())
 7         .pipe(gulp.dest(‘./‘));
 8 });
 9 
10 gulp.task(‘default‘, [‘jsx‘]);

二、Browserify

 1 var gulp = require(‘gulp‘);
 2 var browserify = require(‘browserify‘);
 3 var source = require(‘vinyl-source-stream‘);
 4 var reactify = require(‘reactify‘);
 5 
 6 gulp.task(‘jsx‘, function() {
 7     browserify({
 8         entries: [‘./app.jsx‘],
 9         transform: [reactify]
10     })
11         .bundle()
12         .pipe(source(‘app.js‘))
13         .pipe(gulp.dest(‘./‘));
14 });
15 
16 gulp.task(‘default‘, [‘jsx‘]);     

三、webpack

 

var webpack = require(‘webpack‘)

module.exports = {
	entry: {
		app: ‘./app.jsx‘,
		app2: ‘./app2.jsx‘
	},
	output: {
		path: ‘./‘,
		filename: ‘[name].js‘,
	},
	plugins: [
		new webpack.optimize.CommonsChunkPlugin("common.js")
	],
	module: {
		loaders: [
			{
				test: /\.jsx$/,
				loader: ‘jsx-loader‘,
			}
		]
	}
}

  

React gulp、Browserify、Webpack实例

原文:http://www.cnblogs.com/shamgod/p/5071421.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!