|
@@ -0,0 +1,146 @@
|
|
1
|
+/**
|
|
2
|
+ * Created by robin on 11/10/15.
|
|
3
|
+ */
|
|
4
|
+
|
|
5
|
+module.exports = function(grunt) {
|
|
6
|
+
|
|
7
|
+ grunt.loadNpmTasks('grunt-contrib-clean');
|
|
8
|
+ grunt.loadNpmTasks('grunt-usemin');
|
|
9
|
+ grunt.loadNpmTasks('grunt-contrib-concat');
|
|
10
|
+ grunt.loadNpmTasks('grunt-contrib-uglify');
|
|
11
|
+ grunt.loadNpmTasks('grunt-contrib-copy');
|
|
12
|
+ grunt.loadNpmTasks('grunt-contrib-cssmin');
|
|
13
|
+ grunt.loadNpmTasks('grunt-contrib-less');
|
|
14
|
+
|
|
15
|
+ var path = require('path');
|
|
16
|
+
|
|
17
|
+ grunt.initConfig({
|
|
18
|
+ globals: {
|
|
19
|
+ releasePath: 'build/release/camotion',
|
|
20
|
+ appFolder: 'camotion',
|
|
21
|
+ staticFiles: [
|
|
22
|
+ 'views/**/*.html',
|
|
23
|
+ 'index.html',
|
|
24
|
+ 'img/**',
|
|
25
|
+ 'fonts/**'
|
|
26
|
+ ]
|
|
27
|
+ },
|
|
28
|
+ useminPrepare: {
|
|
29
|
+ release: '<%= globals.appFolder %>/index.html',
|
|
30
|
+ options: {
|
|
31
|
+ flow: {
|
|
32
|
+ release: {
|
|
33
|
+ steps: {
|
|
34
|
+ 'js': [
|
|
35
|
+ 'concat',
|
|
36
|
+ {
|
|
37
|
+ name: 'uglify',
|
|
38
|
+ createConfig: function (context, block) {
|
|
39
|
+ var cfg = {files: []},
|
|
40
|
+ filesDef = {};
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+ filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
|
|
44
|
+ filesDef.src = [];
|
|
45
|
+ context.inFiles.forEach(function (inFile) {
|
|
46
|
+ filesDef.src.push(path.join(context.inDir, inFile));
|
|
47
|
+ });
|
|
48
|
+
|
|
49
|
+ cfg.files.push(filesDef);
|
|
50
|
+ return cfg;
|
|
51
|
+ }
|
|
52
|
+ }
|
|
53
|
+ ],
|
|
54
|
+ 'css': ['concat',
|
|
55
|
+ {
|
|
56
|
+ name: 'cssmin',
|
|
57
|
+ createConfig: function (context, block) {
|
|
58
|
+ var cfg = {files: []},
|
|
59
|
+ filesDef = {};
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+ filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
|
|
63
|
+ filesDef.src = [];
|
|
64
|
+ context.inFiles.forEach(function (inFile) {
|
|
65
|
+ filesDef.src.push(path.join(context.inDir, inFile));
|
|
66
|
+ });
|
|
67
|
+
|
|
68
|
+ cfg.files.push(filesDef);
|
|
69
|
+ return cfg;
|
|
70
|
+ }
|
|
71
|
+ }],
|
|
72
|
+ 'less': [
|
|
73
|
+ {
|
|
74
|
+ name: 'less',
|
|
75
|
+ createConfig: function (context, block) {
|
|
76
|
+ var cfg = {files: []},
|
|
77
|
+ filesDef = {};
|
|
78
|
+
|
|
79
|
+ context.options.generated.options = {
|
|
80
|
+ cleancss: true
|
|
81
|
+ };
|
|
82
|
+
|
|
83
|
+ filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
|
|
84
|
+ filesDef.src = [];
|
|
85
|
+ context.inFiles.forEach(function (inFile) {
|
|
86
|
+ filesDef.src.push(path.join(context.inDir, inFile));
|
|
87
|
+ });
|
|
88
|
+
|
|
89
|
+ cfg.files.push(filesDef);
|
|
90
|
+ return cfg;
|
|
91
|
+ }
|
|
92
|
+ }
|
|
93
|
+ ]
|
|
94
|
+ },
|
|
95
|
+ post: {
|
|
96
|
+
|
|
97
|
+ }
|
|
98
|
+ }
|
|
99
|
+ }
|
|
100
|
+ }
|
|
101
|
+ },
|
|
102
|
+ usemin: {
|
|
103
|
+ html: '<%= globals.releasePath %>/index.html',
|
|
104
|
+ options: {
|
|
105
|
+ blockReplacements: {
|
|
106
|
+ less: function (block) {
|
|
107
|
+ return '<link rel=\"stylesheet\" href=\"' + block.dest + '\"/>';
|
|
108
|
+ }
|
|
109
|
+ }
|
|
110
|
+ }
|
|
111
|
+ },
|
|
112
|
+ copy: {
|
|
113
|
+ release: {
|
|
114
|
+ files: [
|
|
115
|
+ {
|
|
116
|
+ expand: true,
|
|
117
|
+ cwd:'<%= globals.appFolder %>/',
|
|
118
|
+ src: ['<%= globals.staticFiles %>'],
|
|
119
|
+ dest: '<%= globals.releasePath %>'
|
|
120
|
+ },
|
|
121
|
+ {
|
|
122
|
+ expand: true,
|
|
123
|
+ cwd:'<%= globals.appFolder %>/../bower_components/flat-ui/dist/fonts/',
|
|
124
|
+ src: ['**'],
|
|
125
|
+ dest: '<%= globals.releasePath %>/fonts/'
|
|
126
|
+ }
|
|
127
|
+ ]
|
|
128
|
+ }
|
|
129
|
+ },
|
|
130
|
+ clean: {
|
|
131
|
+ release: ['<%= globals.releasePath %>/*']
|
|
132
|
+ }
|
|
133
|
+ });
|
|
134
|
+ grunt.registerTask('release', [
|
|
135
|
+ 'clean:release',
|
|
136
|
+ 'useminPrepare:release',
|
|
137
|
+ 'concat:generated',
|
|
138
|
+ 'uglify:generated',
|
|
139
|
+ 'copy:release',
|
|
140
|
+ 'cssmin:generated',
|
|
141
|
+ 'less:generated',
|
|
142
|
+ 'usemin'
|
|
143
|
+ ]);
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+};
|