forked from craftcms/commerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (57 loc) · 2.22 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
58
59
60
61
62
63
64
65
66
67
68
var gulp = require('gulp');
var es = require('event-stream');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
sass.compiler = require('node-sass');
var assetsPath = './src/web/assets/';
var libPath = './lib/';
var jsDeps = [
{ srcGlob: 'node_modules/chart.js/dist/Chart.bundle.min.js', dest: libPath + 'chart-js' },
{ srcGlob: 'node_modules/moment/min/moment-with-locales.min.js', dest: libPath + 'moment' },
{ srcGlob: 'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.min.js', dest: libPath + 'chartjs-adapter-moment' },
{ srcGlob: 'node_modules/deepmerge/dist/umd.js', dest: libPath + 'deepmerge' },
];
function commerceStatsSass () {
return gulp.src(assetsPath+'statwidgets/src/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('statwidgets.css'))
.pipe(gulp.dest(assetsPath+'statwidgets/dist/css'));
};
function commerceSass () {
return gulp.src(assetsPath+'commercecp/src/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('commercecp.css'))
.pipe(gulp.dest(assetsPath+'commercecp/dist/css'));
};
function commerceJs() {
return gulp.src(assetsPath+'commercecp/src/**/*.js')
.pipe(concat('commercecp.js'))
.pipe(gulp.dest(assetsPath+'commercecp/dist/js'));
};
function libDeps() {
var streams = [];
// Minify & move the JS deps
jsDeps.forEach(function(dep) {
streams.push(
gulp.src(dep.srcGlob)
//.pipe(gulp.dest(dest))
.pipe(sourcemaps.init())
// .pipe(uglify())
//.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dep.dest))
);
});
return es.merge(streams);
};
exports.default = function(done) {
libDeps();
gulp.series(commerceJs, commerceSass, commerceStatsSass)(done);
}
exports.watch = function() {
gulp.watch(assetsPath+'commercecp/src/scss/**/*.scss', commerceSass);
gulp.watch(assetsPath+'statwidgets/src/scss/**/*.scss', commerceStatsSass);
gulp.watch(assetsPath+'commercecp/src/**/*.js', commerceJs);
}