forked from FidelityInternational/djangocms-navigation
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
79 lines (68 loc) · 2.34 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
// #####################################################################################################################
// #IMPORTS#
var gulp = require('gulp');
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var fs = require('fs');
var gulpif = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps');
// var eslint = require('gulp-eslint');
var webpack = require('webpack');
var argv = require('minimist')(process.argv.slice(2)); // eslint-disable-line
// #####################################################################################################################
// #SETTINGS#
var options = {
debug: argv.debug
};
var PROJECT_ROOT = __dirname + '/djangocms_navigation/static/djangocms_navigation';
var PROJECT_PATH = {
js: PROJECT_ROOT + '/js',
sass: PROJECT_ROOT + '/sass',
css: PROJECT_ROOT + '/css',
};
var PROJECT_PATTERNS = {
js: [
PROJECT_PATH.js + '/*.js',
'!' + PROJECT_PATH.js + '/dist/*.js'
],
sass: [
PROJECT_PATH.sass + '/**/*.{scss,sass}'
],
icons: [
PROJECT_PATH.icons + '/src/*.svg'
]
};
gulp.task('lint', ['lint:javascript']);
gulp.task('lint:javascript', function () {
// DOCS: http://eslint.org
return gulp.src(PROJECT_PATTERNS.js)
.pipe(gulpif(!process.env.CI, plumber()))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(gulpif(!process.env.CI, plumber.stop()));
});
var webpackBundle = function (opts) {
var webpackOptions = opts || {};
webpackOptions.PROJECT_PATH = PROJECT_PATH;
webpackOptions.debug = options.debug;
return function (done) {
var config = require('./webpack.config')(webpackOptions);
webpack(config, function (err, stats) {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack]', stats.toString({ maxModules: Infinity, colors: true, optimizationBailout: true }));
if (typeof done !== 'undefined' && (!opts || !opts.watch)) {
done();
}
});
};
};
gulp.task('bundle:watch', webpackBundle({ watch: true }));
gulp.task('bundle', webpackBundle());
gulp.task('watch', function () {
gulp.start('bundle:watch');
// gulp.watch(PROJECT_PATTERNS.js, ['lint']);
});
gulp.task('default', ['watch']);