-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·57 lines (52 loc) · 1.51 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
46
47
48
49
50
51
52
53
54
55
56
57
/**
* baserCMS : Based Website Development Project <https://basercms.net>
* Copyright (c) NPO baser foundation <https://baserfoundation.org/>
*
* @copyright Copyright (c) NPO baser foundation
* @link https://basercms.net baserCMS Project
* @since 5.0.0
* @license https://basercms.net/license/index.html MIT License
*/
const gulp = require("gulp");
const webpack = require('webpack');
const webpackStream = require('webpack-stream');
const webpackConfig = require("./webpack.config");
const plumber = require('gulp-plumber');
const sass = require('gulp-sass')(require('sass'));
const postcss = require("gulp-postcss");
const cssImport = require("postcss-import");
const JS_DEV_DIR = './src/**/*.js';
const JS_DIST_DIR = './webroot/';
const CSS_DEV_DIR = ['./src/**/*.scss', '!./src/css/vendor/**/*.scss'];
const CSS_DIST_DIR = './webroot/';
gulp.task('css', () => {
const plugins = [
cssImport({
path: [ '../../node_modules' ]
})
];
return gulp
.src(CSS_DEV_DIR, {
sourcemaps: true
})
.pipe(plumber({
errorHandler: function (err) {
console.log(err.message);
this.emit('end');
},
}))
.pipe(sass())
.pipe(postcss(plugins))
.pipe(gulp.dest(CSS_DIST_DIR, {
sourcemaps: true
}));
});
gulp.task('bundle', () => {
return webpackStream(webpackConfig, webpack)
.pipe(gulp.dest(JS_DIST_DIR));
});
gulp.task('watch', function(){
gulp.watch(CSS_DEV_DIR, gulp.task('css'));
gulp.watch(JS_DEV_DIR, gulp.task('bundle'));
});
gulp.task('default', gulp.task('watch'));