This repository has been archived by the owner on May 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
76 lines (63 loc) · 1.89 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var watch = require('gulp-watch');
var batch = require('gulp-batch');
var repo_root = __dirname + '/';
var govuk_frontend_toolkit_root =
repo_root + 'node_modules/govuk_frontend_toolkit/stylesheets'; // 1.
var govuk_elements_sass_root =
repo_root + 'node_modules/govuk-elements-sass/public/sass'; // 2.
var product_page_example_scss =
repo_root + '../product-page-example/source/stylesheets/modules';
var assets = './sandboxmgt/assets';
var ignoredFiles =
[ '.*', '#*', 'app_flymake.js' ]
.map(function(p) { return '!'+assets+'/**/'+p; });
// Compile scss files to css
var scssFiles = ignoredFiles.concat(
[ assets + '/scss/*.scss'
]);
gulp.task('styles', function () {
return gulp.src(scssFiles)
.pipe(sass({includePaths: [
govuk_frontend_toolkit_root,
govuk_elements_sass_root,
product_page_example_scss,
repo_root + '../product-page-example/source/stylesheets',
]}).on('error', sass.logError))
.pipe(gulp.dest(assets + '/css'));
});
//script paths
var jsFiles = ignoredFiles.concat(
[ assets + '/javascripts/vendor/jquery/*.js'
, assets + '/javascripts/vendor/polyfills/*.js'
, assets + '/javascripts/govuk/**/*.js'
, assets + '/javascripts/vendor/typeahead.bundle.min.js'
, assets + '/javascripts/*.js'
]);
var jsDest = assets + '/js';
gulp.task('scripts', function() {
return gulp.src(jsFiles)
.pipe(concat('main.js'))
.pipe(gulp.dest(jsDest));
});
gulp.task('watchScripts', function () {
watch(
jsFiles,
{ ignoreInitial: false },
batch(function (events, done) {
gulp.start('scripts', done);
})
);
});
gulp.task('watchStyles', function () {
watch(
scssFiles,
{ ignoreInitial: false },
batch(function (events, done) {
gulp.start('styles', done);
})
);
});