forked from janmarek/react-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (38 loc) · 1.29 KB
/
gulpfile.js
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
/* eslint no-var: 0 */
require('babel/register')();
var path = require('path');
var gulp = require('gulp');
var gulpUtil = require('gulp-util');
var del = require('del');
var createTestTask = require('./js/test/createTestTask');
var createWebpackBuildTask = require('./js/webpack/createBuildTask');
var createWebpackWatchTask = require('./js/webpack/createWatchTask');
var createWebpackRunDevServerTask = require('./js/webpack/createRunDevServerTask');
var config = {
production: false,
};
var paths = {
devServerPort: 4000,
webpackRoot: __dirname,
documentRoot: path.join(__dirname, 'public'),
assetsDir: './public/assets',
publicPath: '/assets/',
scripts: {
src: ['js/**/*.js'],
index: './js/index.js',
outputName: 'bundle.js',
},
styles: {
outputName: 'theme.css',
},
};
gulp.task('clean', function (done) {
del([paths.assetsDir]).then(function () {
done();
});
});
gulp.task('webpack', ['clean'], createWebpackBuildTask(gulpUtil, paths, (config.production ? 'production' : 'dev')));
gulp.task('watch', createWebpackWatchTask(gulpUtil, paths));
gulp.task('dev-server', ['clean'], createWebpackRunDevServerTask(paths));
gulp.task('test', createTestTask(gulp, 'js/**/__tests__/*Test.js'));
gulp.task('default', ['webpack']);