-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
90 lines (79 loc) · 2.86 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Import all the modules we need.
var gulp = require('gulp');
var buffer = require('vinyl-buffer');
var browserSync = require('browser-sync').create();
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var eyeglass = require("eyeglass");
var autoprefixer = require('autoprefixer');
var postcss = require('gulp-postcss');
var webpack = require('webpack');
var gulpWebpack = require('webpack2-stream-watch');
var mergeStream = require('merge-stream');
gulp.task('compile:sass:oiko', function () {
var sassOptions = {
errLogToConsole: true,
outputStyle: 'expanded',
includePaths: [
'node_modules/foundation-sites/scss',
],
eyeglass: {
enableImportOnce: false,
}
};
return gulp
.src('webroot/themes/custom/oiko/scss/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass(eyeglass(sassOptions)).on("error", sass.logError))
.pipe(postcss([ autoprefixer({ browsers: ['last 2 versions', 'ie >= 9'] }) ]))
.pipe(sourcemaps.write())
.pipe(gulp.dest('webroot/themes/custom/oiko/css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('compile:sass', ['compile:sass:oiko']);
gulp.task('compile:js', function () {
// For now, just copy a file out of the node modules folder.
var files = [
'node_modules/foundation-sites/dist/foundation.min.js',
'node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js',
'node_modules/iframe-resizer/js/iframeResizer.min.js',
'node_modules/localforage/dist/localforage.nopromises.min.js'
];
return gulp
.src(files)
.pipe(gulp.dest('webroot/themes/custom/oiko/scripts/vendor'));
});
gulp.task('compile:webpack', function () {
// For now, just copy a file out of the node modules folder.
var files = [
'webroot/modules/custom/oiko_app/js/main.js',
];
return gulp
.src(files)
.pipe(gulpWebpack( require('./webpack.config.js') , webpack))
.pipe(gulp.dest('webroot/modules/custom/oiko_app/dist/'));
});
gulp.task('watch:js', ['compile:js'], function (done) {
browserSync.reload();
done();
});
gulp.task('watch:twig', function (done) {
browserSync.reload();
done();
});
// Main compile task.
gulp.task('compile', ['compile:sass', 'compile:js', 'compile:webpack']);
gulp.task('browsersync', ['compile:js', 'compile:webpack'], function(){
// Watch CSS and JS files
var files = [
'css/*css',
'js/*js',
];
//initialize browsersync
browserSync.init(files);
gulp.watch(['webroot/themes/custom/**/*.js', 'webroot/modules/custom/**/*.js', '!webroot/modules/custom/oiko_app/js/**/*.js'], ['watch:js']);
gulp.watch('webroot/modules/custom/oiko_app/js/**/*.js', ['compile:webpack']);
gulp.watch(['webroot/themes/custom/**/*.twig', 'webroot/modules/custom/**/*.twig'], ['watch:twig']);
gulp.watch(['.drush-cache-rebuild'], ['watch:twig']);
gulp.watch('webroot/themes/custom/**/*.scss', ['compile:sass']);
});