This repository has been archived by the owner on Aug 7, 2018. It is now read-only.
forked from craftcms/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
121 lines (119 loc) · 3.23 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
module.exports = function(grunt) {
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
sass: {
files: ['src/web/assets/**/*.scss'],
tasks: 'sass'
},
cpjs: {
files: ['src/web/assets/cp/src/js/*.js'],
tasks: ['concat', 'uglify:cpjs'],
},
otherjs: {
files: ['src/web/assets/*/dist/*.js', '!src/web/assets/*/dist/*.min.js'],
tasks: ['uglify:otherjs']
},
colorpickerjs: {
files: ['lib/colorpicker/js/colorpicker.js'],
tasks: ['uglify:colorpickerjs']
},
redactorjs: {
files: ['lib/redactor/redactor.js'],
tasks: ['uglify:redactorjs']
}
},
sass: {
options: {
style: 'compact',
unixNewlines: true
},
dist: {
expand: true,
cwd: 'src/web/assets',
src: '**/*.scss',
dest: 'src/web/assets',
rename: function(dest, src) {
// Keep them where they came from
return dest + '/' + src;
},
ext: '.css'
}
},
concat: {
cpjs: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n' +
'(function($){\n\n',
footer: '\n})(jQuery);\n',
},
src: [
'src/web/assets/cp/src/js/Craft.js',
'src/web/assets/cp/src/js/Base*.js',
'src/web/assets/cp/src/js/*.js',
'!(src/web/assets/cp/src/js/Craft.js|src/web/assets/cp/src/js/Base*.js)'
],
dest: 'src/web/assets/cp/dist/js/Craft.js'
}
},
uglify: {
options: {
sourceMap: true,
preserveComments: 'some',
screwIE8: true
},
cpjs: {
src: 'src/web/assets/cp/dist/js/Craft.js',
dest: 'src/web/assets/cp/dist/js/Craft.min.js'
},
otherjs: {
expand: true,
cwd: 'src/web/assets',
src: ['*/dist/*.js', '!*/dist/*.min.js', '!tests/dist/tests.js'],
dest: 'src/web/assets',
rename: function(dest, src) {
// Keep them where they came from
return dest + '/' + src;
},
ext: '.min.js'
},
colorpickerjs: {
src: 'lib/colorpicker/js/colorpicker.js',
dest: 'lib/colorpicker/js/colorpicker.min.js'
},
redactorjs: {
src: 'lib/redactor/redactor.js',
dest: 'lib/redactor/redactor.min.js'
}
},
jshint: {
options: {
expr: true,
laxbreak: true,
loopfunc: true, // Supresses "Don't make functions within a loop." errors
shadow: true,
strict: false,
'-W041': true,
'-W061': true
},
beforeconcat: [
'gruntfile.js',
'src/web/assets/**/*.js',
'!src/web/assets/**/*.min.js',
'!src/web/assets/cp/dist/js/Craft.js'
],
afterconcat: [
'src/web/assets/cp/dist/js/Craft.js'
]
}
});
//Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
// Default task(s).
grunt.registerTask('default', ['sass', 'jshint:beforeconcat', 'concat', 'jshint:afterconcat', 'uglify']);
};