forked from owlsomely/angular-image-zoom
/
Gruntfile.js
134 lines (132 loc) · 3.26 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
'use strict';
/**
*
*/
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
development: {
options: {
paths: ['src/less'],
strictMath: true
},
files: {
'dist/image-zoom.css': 'src/less/image-zoom.less'
}
},
minify: {
options: {
compress: true,
cleancss: true,
sourceMap: true,
outputSourceFiles: true,
sourceMapURL: 'image-zoom.min.css.map',
sourceMapFilename: 'image-zoom.min.css.map',
report: 'min',
keepSpecialComments: '0'
},
files: {
'dist/image-zoom.min.css': 'dist/image-zoom.css'
}
}
},
concat: {
app: {
options: {
separator: ';',
// Replace all 'use strict' statements in the code with a single one at the top
banner: "'use strict';\n",
process: function (src, filepath) {
var newSrc = src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
return newSrc;
},
},
src: [
'src/js/image-zoom.js',
],
dest: 'dist/image-zoom.js',
},
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= pkg.author.name %> <%= pkg.license %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>' +
' */',
mangle: false,
preserveComments: false,
compress: {
drop_console: true
},
report: 'min'
},
production: {
files: {
'dist/image-zoom.min.js': ['dist/image-zoom.js'],
}
}
},
copy: {
templateToDist: {
files: [{
expand: true,
flatten: true,
src: 'src/template/*.html',
dest: 'dist',
filter: 'isFile'
}]
}
},
watch: {
css: {
files: ['src/less/*.less'],
tasks: ['less'],
options: {
livereload: false,
},
},
js: {
files: ['src/js/*.js'],
tasks: ['concat', 'uglify'],
options: {
livereload: false,
},
},
template: {
files: ['src/template/*.html'],
tasks: ['copy:templateToDist'],
options: {
livereload: false,
},
}
},
express: { // to server file on local machine
server: {
options: {
port: 9000,
bases: ['demo', 'dist']
}
}
},
concurrent: {
devWatch: ['demoServer', 'watch'],
options: {
logConcurrentOutput: true
}
},
});
grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-concurrent');
// build
grunt.registerTask('build', ['copy:templateToDist', 'less', 'concat', 'uglify']);
//development
grunt.registerTask('dev', ['concurrent:devWatch']);
grunt.registerTask('demoServer', ['express', 'express-keepalive']);
};