forked from selectize/selectize.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
110 lines (105 loc) · 2.52 KB
/
Gruntfile.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-replace');
grunt.registerTask('default', [
'bower:install',
'concat:js',
'concat:css',
'replace',
'concat:js_standalone',
'uglify'
]);
var plugins = (grunt.option('plugins') || '*').split(/\s*,\s*/).join(',');
if (plugins !== '*') plugins = '{' + plugins + '}';
var files_js = [
'src/contrib/*.js',
'src/*.js',
'!src/selectize.js',
'!src/selectize.jquery.js',
'src/selectize.js',
'src/selectize.jquery.js',
'src/plugins/' + plugins + '/*.js'
];
var files_js_dependencies = [
'bower_components/sifter/sifter.js'
];
var files_css = [
'src/*.css',
'src/plugins/' + plugins + '/*.css'
];
grunt.initConfig({
pkg: grunt.file.readJSON('bower.json'),
bower: {
install: {
options: {
targetDir: './bower_components',
layout: 'byComponent'
}
}
},
replace: {
options: {prefix: '@@'},
main: {
options: {
variables: {
'version': '<%= pkg.version %>',
'js': '<%= grunt.file.read("dist/selectize.js").replace(/\\n/g, "\\n\\t") %>',
'css': '<%= grunt.file.read("dist/selectize.css") %>',
},
},
files: [
{src: ['templates/wrapper.js'], dest: 'dist/selectize.js'},
{src: ['templates/wrapper.css'], dest: 'dist/selectize.css'},
{src: ['templates/wrapper.css'], dest: 'dist/standalone/selectize.css'}
]
}
},
concat: {
options: {
stripBanners: true,
separator: grunt.util.linefeed + grunt.util.linefeed
},
js: {
files: {
'dist/selectize.js': files_js,
}
},
js_standalone: {
options: {
stripBanners: false
},
files: {
'dist/standalone/selectize.js': (function() {
var files = [];
for (var i = 0, n = files_js_dependencies.length; i < n; i++) {
files.push(files_js_dependencies[i]);
}
files.push('dist/selectize.js');
return files;
})()
}
},
css: {
files: {
'dist/selectize.css': files_css,
'dist/standalone/selectize.css': files_css
}
}
},
uglify: {
main: {
options: {
'banner': '/*! selectize.js - v<%= pkg.version %> | https://github.com/brianreavis/selectize.js | Apache License (v2) */\n',
'report': 'gzip',
'ascii-only': true
},
files: {
'dist/selectize.min.js': ['dist/selectize.js'],
'dist/standalone/selectize.min.js': ['dist/standalone/selectize.js']
}
}
}
});
};