-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·139 lines (122 loc) · 3.34 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
module.exports = function(grunt) {
'use strict'
// Force use of Unix newlines
grunt.util.linefeed = '\n';
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-concat-css');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-riot');
// grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// less
less: {
development: {
options: {
plugins: [
new(require('less-plugin-autoprefix'))({
browsers: ["last 2 versions"]
})
]
},
files: {
"<%= pkg.dist %>css/main.css": "<%= pkg.css %>less/main.less"
}
}
},
// css min
cssmin: {
target: {
files: [{
expand: true,
cwd: "<%= pkg.dist %>css",
dest: "<%= pkg.dist %>css",
src: ["*.css", "!*.min.css"],
ext: ".min.css"
}]
}
},
// coffee script
coffee: {
compile: {
options: {
bare: true,
},
files: {
'<%= pkg.tmp %>all_coffee.js': [
'<%= pkg.js %>coffee/main.coffee',
]
}
},
},
// riot tags
riot: {
options: {
concat: true
},
task: {
src: [
'<%= pkg.js %>tags/*.tag',
],
dest: '<%= pkg.tmp %>tags.js',
}
},
// concatenar los ficheros js
concat: {
options: {
separator: ';',
},
// unimos los ficheros compilados
dist: {
src: [
// lib
'<%= pkg.bower_components %>jquery/jquery.min.js', // [v < 2]
'<%= pkg.node_modules %>riot/riot.min.js',
'<%= pkg.node_modules %>riot-route/dist/route.min.js',
// xstrap components
'<%= pkg.bower_components %>xstrap/offcanvas/js/ie10-viewport-bug-workaround.js',
'<%= pkg.bower_components %>xstrap/offcanvas/js/offcanvas.js',
'<%= pkg.bower_components %>xstrap/transitions/js/transition.js',
'<%= pkg.bower_components %>forms/js/forms.js',
// tags
'<%= pkg.tmp %>tags.js',
// all coffee files compiled
'<%= pkg.tmp %>all_coffee.js',
],
dest: '<%= pkg.dist %>js/main.js',
}
},
// uglify de js
uglify: {
options: {
mangle: true
},
my_target: {
files: {
'<%= pkg.dist %>js/main.min.js': ['<%= pkg.dist %>js/main.js']
}
}
},
// ficheros a observar que lanzarán la función default (varias)
watch: {
scripts: {
tasks: ['default'],
options: {
interrupt: false,
},
files: [
'<%= pkg.css %>less/*.less',
'<%= pkg.js %>tags/*.tag',
'<%= pkg.js %>coffee/*.coffee'
]
}
}
});
grunt.registerTask("dev", ["less", "riot", "coffee", "concat"]);
grunt.registerTask("prod", ["dev", "cssmin", "uglify"]);
grunt.registerTask("default", ["prod"]);
};