-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
63 lines (54 loc) · 1.86 KB
/
Copy pathgulpfile.js
File metadata and controls
63 lines (54 loc) · 1.86 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
var
gulp = require('gulp'),
sass = require('gulp-sass'),
cached = require('gulp-cached'),
autoprefixer = require('gulp-autoprefixer'),
minify = require('gulp-minify-css'),
sourcemaps = require('gulp-sourcemaps'),
browserSync = require('browser-sync').create(),
reload = browserSync.reload,
rename = require('gulp-rename'),
webpack = require('gulp-webpack'),
webpackServer = require('./webpack-server');
var cssPath = "lib/css/**/*.scss";
var cssOutPath = "public/assets/css";
var jsPath = "lib/entry.js";
var jsOutName = "dataloader.min.js";
var jsOutPath = "dist";
var jsPublicPath = "public/assets/js";
gulp.task('webpack-hot', webpackServer);
gulp.task('browsersync', function() {
browserSync.init({
proxy: '0.0.0.0:8081',
port: 8083
});
gulp.watch(cssPath, ['browsersync-build']);
gulp.watch('public/**/*.html', reload);
});
gulp.task('browsersync-build', function() {
return gulp.src(cssPath)
.pipe(sass({errLogToConsole: true }))
.pipe(cached('styles'))
.pipe(autoprefixer({ browsers: ['last 2 versions']}))
.pipe(gulp.dest(cssOutPath))
.pipe(reload({stream: true}));
});
gulp.task('build_styles', function() {
return gulp.src(cssPath)
.pipe(sass({errLogToConsole: true }))
.pipe(autoprefixer({ browsers: ['last 2 versions']}))
.pipe(minify({compatibility: 'ie9'}))
.pipe(gulp.dest(cssOutPath));
});
gulp.task('build_js', function() {
return gulp.src(jsPath)
.pipe(webpack(require('./webpack.config.js')))
.pipe(rename(jsOutName))
.pipe(gulp.dest(jsOutPath))
.pipe(gulp.dest(jsPublicPath));
});
gulp.task('watch', ['build_js'], function() {
gulp.watch('./lib/**/*.js', ['build_js']);
});
gulp.task('dev', ['browsersync', 'webpack-hot']);
gulp.task('default', ['build_js', 'build_styles']);