2014-08-27 02:01:42 +04:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
// Full list of files that must be included by RequireJS
|
2014-10-15 05:12:57 +04:00
|
|
|
includes = [
|
|
|
|
'jquery.select2'
|
|
|
|
];
|
2014-08-27 02:01:42 +04:00
|
|
|
|
2014-10-15 05:12:57 +04:00
|
|
|
amdIncludes = [
|
|
|
|
'almond'
|
|
|
|
];
|
|
|
|
|
|
|
|
fullIncludes = [
|
2014-11-05 19:25:41 +03:00
|
|
|
'jquery',
|
2015-01-03 04:32:14 +03:00
|
|
|
'jquery.mousewheel',
|
2014-11-25 23:59:13 +03:00
|
|
|
|
|
|
|
'select2/compat/matcher',
|
2015-01-15 22:36:54 +03:00
|
|
|
'select2/compat/initSelection',
|
|
|
|
'select2/compat/query',
|
2014-11-25 23:59:13 +03:00
|
|
|
|
|
|
|
'select2/dropdown/attachContainer'
|
2014-10-15 05:12:57 +04:00
|
|
|
].concat(includes);
|
2014-08-27 02:01:42 +04:00
|
|
|
|
2014-11-01 05:17:21 +03:00
|
|
|
var i18nModules = [];
|
|
|
|
var i18nPaths = {};
|
|
|
|
|
|
|
|
var i18nFiles = grunt.file.expand({
|
|
|
|
cwd: 'src/js'
|
|
|
|
}, 'select2/i18n/*.js');
|
|
|
|
|
|
|
|
for (var i = 0; i < i18nFiles.length; i++) {
|
|
|
|
var file = i18nFiles[i];
|
|
|
|
var name = file.split('.')[0];
|
|
|
|
|
|
|
|
i18nModules.push({
|
|
|
|
name: name
|
|
|
|
});
|
|
|
|
|
|
|
|
i18nPaths[name] = '../../' + name;
|
|
|
|
}
|
|
|
|
|
2014-08-27 02:01:42 +04:00
|
|
|
grunt.initConfig({
|
2014-11-25 16:36:01 +03:00
|
|
|
clean: {
|
|
|
|
docs: ['docs/_site']
|
|
|
|
},
|
|
|
|
|
2014-08-27 02:01:42 +04:00
|
|
|
uglify: {
|
2014-10-15 05:12:57 +04:00
|
|
|
'dist': {
|
2014-08-27 02:01:42 +04:00
|
|
|
src: 'dist/js/select2.js',
|
|
|
|
dest: 'dist/js/select2.min.js'
|
|
|
|
},
|
2014-10-15 05:12:57 +04:00
|
|
|
'dist.full': {
|
2014-08-27 02:01:42 +04:00
|
|
|
src: 'dist/js/select2.full.js',
|
|
|
|
dest: 'dist/js/select2.full.min.js'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
qunit: {
|
|
|
|
all: [
|
2014-10-15 05:12:57 +04:00
|
|
|
'tests/**/*.html'
|
2014-08-27 02:01:42 +04:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2014-11-25 16:36:01 +03:00
|
|
|
'gh-pages': {
|
|
|
|
options: {
|
|
|
|
base: 'docs',
|
2015-01-03 05:08:19 +03:00
|
|
|
branch: 'master',
|
2014-11-25 16:36:01 +03:00
|
|
|
clone: 'node_modules/grunt-gh-pages/repo',
|
|
|
|
message: 'Updated docs with master',
|
2014-11-26 00:23:53 +03:00
|
|
|
push: true,
|
2015-01-03 05:08:19 +03:00
|
|
|
repo: 'git@github.com:select2/select2.github.io.git'
|
2014-11-25 16:36:01 +03:00
|
|
|
},
|
|
|
|
src: '**'
|
|
|
|
},
|
|
|
|
|
2014-11-04 03:09:38 +03:00
|
|
|
jekyll: {
|
|
|
|
options: {
|
|
|
|
src: 'docs',
|
|
|
|
dest: 'docs/_site'
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
d: null
|
|
|
|
},
|
|
|
|
serve: {
|
|
|
|
options: {
|
|
|
|
serve: true,
|
|
|
|
watch: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-09-21 23:21:43 +04:00
|
|
|
jshint: {
|
|
|
|
options: {
|
|
|
|
jshintrc: true
|
|
|
|
},
|
|
|
|
code: {
|
2014-11-01 02:10:38 +03:00
|
|
|
src: ['src/js/**/*.js']
|
2014-09-21 23:21:43 +04:00
|
|
|
},
|
|
|
|
tests: {
|
2014-11-01 02:10:38 +03:00
|
|
|
src: ['tests/**/*.js']
|
2014-09-21 23:21:43 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-27 02:01:42 +04:00
|
|
|
sass: {
|
|
|
|
dist: {
|
|
|
|
options: {
|
2014-11-01 02:10:38 +03:00
|
|
|
outputStyle: 'compressed'
|
2014-08-27 02:01:42 +04:00
|
|
|
},
|
|
|
|
files: {
|
2014-11-01 02:10:38 +03:00
|
|
|
'dist/css/select2.min.css': [
|
|
|
|
'src/scss/core.scss',
|
|
|
|
'src/scss/theme/default/layout.css'
|
2014-08-27 02:01:42 +04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
dev: {
|
|
|
|
options: {
|
2014-11-01 02:10:38 +03:00
|
|
|
outputStyle: 'nested'
|
2014-08-27 02:01:42 +04:00
|
|
|
},
|
|
|
|
files: {
|
2014-11-01 02:10:38 +03:00
|
|
|
'dist/css/select2.css': [
|
|
|
|
'src/scss/core.scss',
|
|
|
|
'src/scss/theme/default/layout.css'
|
2014-08-27 02:01:42 +04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-01-13 03:56:25 +03:00
|
|
|
symlink: {
|
|
|
|
docs: {
|
|
|
|
cwd: 'dist',
|
|
|
|
expand: true,
|
|
|
|
overwrite: false,
|
|
|
|
src: [
|
|
|
|
'*'
|
|
|
|
],
|
|
|
|
dest: 'docs/dist',
|
|
|
|
filter: 'isDirectory'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-27 02:01:42 +04:00
|
|
|
requirejs: {
|
2014-11-01 02:10:38 +03:00
|
|
|
'dist': {
|
2014-08-27 02:01:42 +04:00
|
|
|
options: {
|
2014-11-01 02:10:38 +03:00
|
|
|
baseUrl: 'src/js',
|
|
|
|
optimize: 'none',
|
|
|
|
name: 'select2/core',
|
|
|
|
out: 'dist/js/select2.js',
|
2014-10-15 05:12:57 +04:00
|
|
|
include: amdIncludes.concat(includes),
|
2014-08-27 02:01:42 +04:00
|
|
|
paths: {
|
2014-11-01 02:10:38 +03:00
|
|
|
almond: '../../vendor/almond-0.2.9',
|
|
|
|
jquery: 'jquery.shim'
|
2014-11-01 03:15:17 +03:00
|
|
|
},
|
|
|
|
wrap: grunt.file.readJSON('src/js/banner.json')
|
2014-08-27 02:01:42 +04:00
|
|
|
}
|
|
|
|
},
|
2014-11-01 02:10:38 +03:00
|
|
|
'dist.full': {
|
2014-08-27 02:01:42 +04:00
|
|
|
options: {
|
2014-11-01 02:10:38 +03:00
|
|
|
baseUrl: 'src/js',
|
|
|
|
optimize: 'none',
|
|
|
|
name: 'select2/core',
|
|
|
|
out: 'dist/js/select2.full.js',
|
2014-10-15 05:12:57 +04:00
|
|
|
include: amdIncludes.concat(fullIncludes),
|
2014-08-27 02:01:42 +04:00
|
|
|
paths: {
|
2014-11-01 02:10:38 +03:00
|
|
|
almond: '../../vendor/almond-0.2.9',
|
2015-01-22 22:49:39 +03:00
|
|
|
jquery: 'jquery.shim',
|
2015-01-03 04:32:14 +03:00
|
|
|
'jquery.mousewheel': '../../vendor/jquery.mousewheel'
|
2014-11-01 03:15:17 +03:00
|
|
|
},
|
|
|
|
wrap: grunt.file.readJSON('src/js/banner.json')
|
2014-08-27 02:01:42 +04:00
|
|
|
}
|
|
|
|
},
|
2014-11-01 02:10:38 +03:00
|
|
|
'amd': {
|
2014-08-27 02:01:42 +04:00
|
|
|
options: {
|
2014-11-01 02:10:38 +03:00
|
|
|
baseUrl: 'src/js',
|
|
|
|
optimize: 'none',
|
|
|
|
name: 'select2/core',
|
|
|
|
out: 'dist/js/select2.amd.js',
|
2014-10-16 03:26:38 +04:00
|
|
|
include: includes,
|
2014-08-27 02:01:42 +04:00
|
|
|
paths: {
|
2014-11-01 02:10:38 +03:00
|
|
|
jquery: 'empty:'
|
2014-11-01 03:15:17 +03:00
|
|
|
},
|
2015-01-22 22:49:39 +03:00
|
|
|
wrap: grunt.file.readJSON('src/js/banner.amd.json')
|
2014-08-27 02:01:42 +04:00
|
|
|
}
|
|
|
|
},
|
2014-11-01 02:10:38 +03:00
|
|
|
'amd.full': {
|
2014-08-27 02:01:42 +04:00
|
|
|
options: {
|
2014-11-01 02:10:38 +03:00
|
|
|
baseUrl: 'src/js',
|
|
|
|
optimize: 'none',
|
|
|
|
name: 'select2/core',
|
|
|
|
out: 'dist/js/select2.amd.full.js',
|
2014-10-15 05:12:57 +04:00
|
|
|
include: fullIncludes,
|
2014-08-27 02:01:42 +04:00
|
|
|
paths: {
|
2015-01-03 04:32:14 +03:00
|
|
|
jquery: 'empty:',
|
|
|
|
'jquery.mousewheel': '../../vendor/jquery.mousewheel'
|
2014-11-01 03:15:17 +03:00
|
|
|
},
|
2015-01-22 22:49:39 +03:00
|
|
|
wrap: grunt.file.readJSON('src/js/banner.amd.json')
|
2014-08-27 02:01:42 +04:00
|
|
|
}
|
2014-11-01 05:17:21 +03:00
|
|
|
},
|
|
|
|
'i18n': {
|
|
|
|
options: {
|
|
|
|
baseUrl: 'src/js/select2/i18n',
|
|
|
|
dir: 'dist/js/i18n',
|
|
|
|
paths: i18nPaths,
|
|
|
|
modules: i18nModules,
|
|
|
|
wrap: grunt.file.readJSON('src/js/banner.json')
|
|
|
|
}
|
2014-08-27 02:01:42 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
js: {
|
|
|
|
files: [
|
2014-11-01 02:10:38 +03:00
|
|
|
'src/js/select2/**/*.js',
|
|
|
|
'tests/**/*.js'
|
2014-08-27 02:01:42 +04:00
|
|
|
],
|
|
|
|
tasks: [
|
2014-11-01 02:10:38 +03:00
|
|
|
'compile',
|
|
|
|
'test',
|
2014-10-11 06:17:51 +04:00
|
|
|
'minify'
|
2014-08-27 02:01:42 +04:00
|
|
|
]
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
files: [
|
2014-11-01 02:10:38 +03:00
|
|
|
'src/scss/**/*.scss'
|
2014-08-27 02:01:42 +04:00
|
|
|
],
|
|
|
|
tasks: [
|
2014-11-01 02:10:38 +03:00
|
|
|
'compile',
|
2014-10-11 06:17:51 +04:00
|
|
|
'minify'
|
2014-08-27 02:01:42 +04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-11-25 16:36:01 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
2014-11-01 02:10:38 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-qunit');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-requirejs');
|
2015-01-13 03:56:25 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-symlink');
|
2014-11-01 02:10:38 +03:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
2014-08-27 02:01:42 +04:00
|
|
|
|
2014-11-25 16:36:01 +03:00
|
|
|
grunt.loadNpmTasks('grunt-gh-pages');
|
2014-11-04 03:09:38 +03:00
|
|
|
grunt.loadNpmTasks('grunt-jekyll');
|
2014-11-01 02:10:38 +03:00
|
|
|
grunt.loadNpmTasks('grunt-sass');
|
2014-08-27 02:01:42 +04:00
|
|
|
|
2014-11-01 02:10:38 +03:00
|
|
|
grunt.registerTask('default', ['compile', 'test', 'minify']);
|
2014-08-27 02:01:42 +04:00
|
|
|
|
2014-11-01 03:15:17 +03:00
|
|
|
grunt.registerTask('compile', ['requirejs', 'sass:dev']);
|
2014-11-01 02:10:38 +03:00
|
|
|
grunt.registerTask('minify', ['uglify', 'sass:dist']);
|
|
|
|
grunt.registerTask('test', ['qunit', 'jshint']);
|
2014-11-04 03:09:38 +03:00
|
|
|
|
2015-01-13 03:56:25 +03:00
|
|
|
grunt.registerTask('docs', ['symlink:docs', 'jekyll:serve']);
|
2014-11-04 03:09:38 +03:00
|
|
|
|
2015-01-03 05:08:19 +03:00
|
|
|
grunt.registerTask('docs-release', ['default', 'clean:docs', 'gh-pages']);
|
2014-11-01 02:10:38 +03:00
|
|
|
};
|