-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
44 lines (37 loc) · 1.25 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
'use strict';
var gulp = require('gulp');
var webpack = require('webpack');
var less = require('gulp-less');
var gulpPlumber = require('gulp-plumber');
var path = require('path');
var livereload = require('gulp-livereload');
var webpackConfig = require('./webpack.config');
var WebpackDevServer = require('webpack-dev-server');
gulp.task('less', function() {
return gulp.src('./src/less/main.less')
.pipe(gulpPlumber(onStreamError))
.pipe(less({
paths: [path.join(__dirname, 'src', 'less'), path.join(__dirname, 'node_modules') ]
}))
.pipe(gulp.dest('./public/css'))
.pipe(livereload());
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch('./src/less/**/*.less', ['less']);
});
gulp.task('webpack-dev-server', function() {
var compiler = webpack(webpackConfig);
new WebpackDevServer(compiler, {
contentBase: 'public',
stats: { colors: true }
}).listen(8080, 'localhost', function(err) {
console.log('Server started');
});
});
// Display error message but continue watching
function onStreamError(err) {
console.log(err.message);
this.emit('end'); // End task causing error
}
gulp.task('default', ['less', 'watch'], function() {});