-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.babel.js
65 lines (53 loc) · 1.63 KB
/
gulpfile.babel.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
import path from 'path';
import gulp from 'gulp';
import rename from 'gulp-rename';
import sass from 'gulp-sass';
import webpack from 'webpack-stream';
import webpackConfig from './webpack.config.babel';
import autoprefixer from 'gulp-autoprefixer';
import sourcemaps from 'gulp-sourcemaps';
console.log(__dirname + "\n\n\n");
const scssFiles = [
path.join(__dirname, 'client/src/styles/bundle.scss')
];
gulp.task('scss', function () {
gulp.src(scssFiles)
.pipe(sourcemaps.init())
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(rename({extname: '.min.css'}))
.pipe(sourcemaps.write('./sourcemaps'))
.pipe(gulp.dest('./client/dist'));
});
gulp.task('scss:w', function () {
gulp.watch([
path.join(__dirname, 'client/src/styles/bundle.scss'),
path.join(__dirname, 'client/src/styles/**/*.scss')
], ['scss']);
});
/**
* Bundle JS files
* Need browserify or webpack to work
*/
const jsFiles = [
path.join(__dirname, 'client/src/**/*.js'),
path.join(__dirname, 'client/src/**/**/*.js'),
path.join(__dirname, 'client/src/**/**/**/*.js')
];
gulp.task('js', function () {
return gulp.src(jsFiles)
.pipe(webpack(webpackConfig))
.pipe(gulp.dest('./client/dist'));
});
gulp.task('js:w', function () {
gulp.watch(jsFiles, ['js']);
});
gulp.task('watch', function () {
gulp.watch([
jsFiles,
path.join(__dirname, 'client/src/styles/*.scss'),
path.join(__dirname, 'client/src/styles/**/*.scss')
], ['default']);
});
gulp.task('default', ['scss', 'js']);