forked from laravel/elixir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.js
89 lines (71 loc) · 1.68 KB
/
Config.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
var util = require('gulp-util');
var fs = require('fs');
var _ = require('underscore');
var config = {
production: !! util.env.production,
srcDir: 'app',
publicDir: 'public',
assetsDir: 'resources/assets/',
cssOutput: 'public/css',
jsOutput: 'public/js',
sourcemaps: ! util.env.production,
autoprefix: true,
tasks: [],
collections: [],
watchers: { default: {} },
babelOptions: {
stage: 2,
compact: false
},
autoprefixerOptions: {
browsers: ['last 2 versions'],
cascade: false
}
};
/**
* Designate that the given task should be watched.
*
* @param {string} task
* @param {string} search
* @param {string} group
*/
config.registerWatcher = function(task, search, group) {
group = group || 'default';
this.watchers[group] = this.watchers[group] || {};
this.watchers[group][task] = search;
return this;
};
/**
* Register the given task to be triggered by Gulp.
*
* @param {string} task
*/
config.queueTask = function(task) {
if (! _.contains(this.tasks, task)) {
this.tasks.push(task);
}
return this;
};
/**
* Set the default directory paths.
*
* @param {string} file
*/
config.setDefaultsFrom = function(file) {
var defaults;
if (fs.existsSync(file)) {
defaults = JSON.parse(fs.readFileSync(file, 'utf8'));
_.extend(this, defaults);
}
};
/**
* Store a set of data in a collection.
*
* @param {string} key
* @param {object} data
*/
config.saveTask = function(key, data) {
this.collections[key] = this.collections[key] || [];
this.collections[key].push(data);
}
module.exports = config;