forked from arturadib/strapdown
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgruntfile.js
165 lines (149 loc) · 3.73 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
(function() {
'use strict';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-preprocess');
var pkg = grunt.file.readJSON('package.json');
// Computes a version number with only 2 digits (e.g. '0.4' instead of '0.4.0')
pkg.shortVers = pkg.version.split('.').splice(0, 2).join('.');
pkg.deps = [
// 'vendor/jquery/dist/jquery.js',
'vendor/jquery/dist/jquery.min.js',
'vendor/marked/marked.min.js',
'vendor/google-code-prettify/bin/prettify.min.js',
'vendor/bootstrap/js/scrollspy.js'
];
grunt.initConfig({
pkg: pkg,
preprocess: {
dev: {
files: [{
expand: true,
cwd: 'src/js',
src: ['*.js'],
dest: 'tmp/'
}],
options: {
context: {
DEBUG: true
}
}
},
release: {
files: '<%= preprocess.dev.files %>',
options: {
context: {}
}
}
},
copy: {
pluginDeps: {
expand: true, // enable dynamic options
flatten: true, // to avoid the creation of subdirectories
src: [
'<%= pkg.deps %>',
'vendor/bootstrap/dist/css/bootstrap.min.css'
],
dest: 'demos/vendor/',
},
testDeps: {
expand: true, // enable dynamic options
flatten: true, // to avoid the creation of subdirectories
src: [
'vendor/qunit/qunit/qunit.js',
'vendor/qunit/qunit/qunit.css'
],
dest: 'test/vendor/',
}
},
concat: {
options: {
separator: ';\n'
},
standalone: {
src: [
'<%= pkg.deps %>',
'tmp/strapdown.js',
'tmp/strapdown-toc.js',
'tmp/strapdown-bi.js'
],
dest: 'dist/strapdown.js'
},
plugin: {
src: [
'tmp/strapdown.js',
'tmp/strapdown-toc.js'
],
dest: 'dist/jquery.strapdown.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
// in-place minify. This is to make the loading from the html easier, since the filename is the same.
'<%= concat.standalone.dest %>': ['<%= concat.standalone.dest %>'],
'dist/jquery.strapdown.min.js': ['<%= concat.plugin.dest %>']
}
}
},
qunit: {
files: ['test/**/*.html']
},
jshint: {
files: ['gruntfile.js', 'src/**/*.js', 'test/**/*.js', '!**/vendor/**/*.js'],
options: {
globals: {
console: true,
}
}
},
delta: {
js: {
files: ['<%= jshint.files %>'],
tasks: ['test', 'preprocess:dev', 'concat']
},
less: {
files: ['src/**/*.less'],
tasks: ['less']
}
},
less: {
dist: {
options: {
cleancss: true
},
files: {
'dist/jquery.strapdown.min.css': 'src/less/strapdown.less',
'dist/strapdown.css': 'src/less/strapdown-bi.less'
}
}
},
clean: {
files: {
src: [
'dist/',
'demos/vendor/',
'tmp/'
]
}
}
});
// Renamed to allow running clean and a first build before doing the deltas
grunt.renameTask( 'watch', 'delta' );
grunt.registerTask('test', ['jshint', 'qunit']);
grunt.registerTask('build', ['concat', 'less']);
grunt.registerTask('default', ['clean', 'copy', 'test', 'preprocess:release', 'build', 'uglify']);
grunt.registerTask('watch', ['clean', 'copy', 'test', 'preprocess:dev', 'build', 'delta']);
};
})();