-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
85 lines (77 loc) · 2.35 KB
/
gulpfile.js
File metadata and controls
85 lines (77 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* The idiomatic ReactJS application compiles JSX as a build step, and doesn't use the in-browser JSX transformer.
* This repo uses a very basic gulp + webpack + babel build to write React with ES6, and build it for the browser
* @type {Gulp|exports}
*/
const gulp = require('gulp')
, gwebpack = require('gulp-webpack')
, browserSync = require('browser-sync')
, nodemon = require('gulp-nodemon')
, reload = browserSync.reload
, del = require('del')
, $ = require('gulp-load-plugins')({pattern: ['gulp-*']});
/**
* A simple task to clean any build products
*/
gulp.task('clean', function( cb ) {
del(['build'], cb);
});
/**
* A simple task to copy our HTML file and images to the dist directory
*/
gulp.task('copy', function() {
return gulp.src("./assets/images/**/*.*").pipe(gulp.dest("dist/assets/images"));
});
/**
* The main step is 'pack' this step takes our 'client.js' file, and builds it using Webpack, the babel-loader plugin to
* transpile ES6 and outputs it to the dist directory
*/
gulp.task('pack', function() {
return gulp.src('./client.js')
.pipe(gwebpack({
resolve: {
extensions: ['', '.js', '.jsx']
},
output: {
path: __dirname + '/dist',
filename: 'client.js'
},
module: {
loaders: [
{test: /\.jsx$/, exclude: /node_modules/, loader: 'babel-loader'},
{test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}
]
}
}))
.pipe(gulp.dest('dist/'));
});
/**
* Transpile ES6 & JSX to ES5 so unit testing tools can import the files
*/
gulp.task('transpile', ['clean'], function() {
return gulp.src(['app/**/*.js', 'app/**/*.jsx'])
.pipe($.babel())
.pipe(gulp.dest('build/js'));
});
gulp.task('develop', ['build'],function() {
nodemon({
"execMap": {
"js": "node --harmony",
"jsx": "node --harmony"
},
script: 'server.js'
, ext: 'jsx js'
, tasks: ['build']
})
.on('restart', function() {
console.log('restarted!')
})
})
/**
* The default task is build
*/
gulp.task("default", ["develop"]);
/**
* Define our build task
*/
gulp.task("build", ["copy", "pack"]);