-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (38 loc) · 1.15 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
const browserSync = require('browser-sync').create();
const del = require('del');
const path = require('path');
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const webpackStream = require('webpack-stream');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const sourcePath = './src/';
function clean() {
return del([sourcePath + 'bundle.main.js']);
}
gulp.task('clean', clean);
gulp.task('js', function () {
return gulp.src(sourcePath + 'main.js')
.pipe(sourcemaps.init())
.pipe(webpackStream(webpackConfig))
.pipe(sourcemaps.write(sourcePath))
.pipe(gulp.dest(sourcePath))
.pipe(browserSync.stream());
});
gulp.task('browser-sync', () => {
browserSync.init({
port: 3000,
server: {
baseDir: "src",
serveStaticOptions: {
extensions: ["css", "html", "js"]
}
}
});
gulp.watch(sourcePath + '**/*.*').on('change', browserSync.reload);
});
gulp.task('watch', () => {
gulp.watch(sourcePath + 'components/*.js', ['js']);
gulp.watch(sourcePath + 'components/*.css', ['js']);
});
gulp.task('default', ['js', 'watch', 'browser-sync']);