This repository has been archived by the owner on May 10, 2021. It is now read-only.
forked from craftcms/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
135 lines (133 loc) · 4.61 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
module.exports = function(grunt) {
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
sass: {
files: ['lib/craftcms-sass/_mixins.scss', 'src/web/assets/**/*.scss', '!src/web/assets/pluginstore/**/*.scss'],
tasks: 'css'
},
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', '!src/web/assets/pluginstore/**/*.js'],
tasks: ['uglify:otherjs']
},
colorpickerjs: {
files: ['lib/colorpicker/js/colorpicker.js'],
tasks: ['uglify:colorpickerjs']
}
},
sass: {
options: {
style: 'compact',
unixNewlines: true
},
dist: {
expand: true,
cwd: 'src/web/assets',
src: [
'**/*.scss',
'!pluginstore/**/*.scss'
],
dest: 'src/web/assets',
rename: function(dest, src) {
// Keep them where they came from
return dest + '/' + src;
},
ext: '.css'
}
},
postcss: {
options: {
map: true,
processors: [
require('autoprefixer')({browsers: 'last 2 versions'})
]
},
dist: {
expand: true,
cwd: 'src/web/assets',
src: [
'**/*.css',
'!pluginstore/**/*.css'
],
dest: 'src/web/assets'
}
},
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)',
'!src/web/assets/pluginstore/**/*.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'
}
},
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',
'!src/web/assets/pluginstore/**/*.js'
],
afterconcat: [
'src/web/assets/cp/dist/js/Craft.js'
]
}
});
//Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-postcss');
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('css', ['sass', 'postcss']);
grunt.registerTask('js', ['jshint:beforeconcat', 'concat', 'jshint:afterconcat', 'uglify']);
grunt.registerTask('cpjs', ['concat', 'uglify:cpjs']);
grunt.registerTask('default', ['css', 'js']);
};