This repository has been archived by the owner on Apr 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
151 lines (143 loc) · 3.17 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
140
141
142
143
144
145
146
147
148
149
150
151
'use strict';
var _ = require('lodash-node');
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
var tmp = '.tmp/';
var preBuiltDest = tmp + 'build-prep';
var builtDest = tmp + 'built';
var templatesFile = preBuiltDest + '/formly-templates.js';
var targetFilename = 'angular-formly-templates-vanilla';
var concatFile = builtDest + '/' + targetFilename + '.js';
var uglifyFile = builtDest + '/' + targetFilename + '.min.js';
var config = {
pkg: grunt.file.readJSON('package.json'),
formlyConfig: {
base: 'src',
dist: 'dist'
},
clean: {
tmp: '.tmp/**/*',
dist: 'dist/**/*'
},
jshint: {
src: ['src/**/*.js']
},
mocha: {
all: {
src: ['tests/testrunner.html']
},
options: {
run: true
}
},
watch: {
build: {
files: ['<%= formlyConfig.base %>/**/*.{js,html}'],
tasks: ['build']
}
},
copy: {
build: {
files: [
{
expand: true,
cwd: '<%= formlyConfig.base %>/',
src: ['**/*.*', '!**/*Spec.js'],
dest: preBuiltDest
}
]
},
dist: {
expand: true,
cwd: '.tmp/',
src: '**/built/**/*.*',
dest: 'dist/',
flatten: true,
filter: 'isFile'
}
},
ngtemplates: {
default: {
options: {
module: 'formlyVanilla',
append: true,
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: false,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
},
files: [
{
cwd: preBuiltDest + '/',
src: [ 'fields/**/*.html', 'wrappers/**/*.html' ],
dest: templatesFile
}
]
}
},
concat: {
default: {
src: [
preBuiltDest + '/modules/*.js',
preBuiltDest + '/**/*.js'
],
dest: concatFile
}
},
ngAnnotate: {
default: {
src: concatFile,
dest: concatFile
}
},
uglify: {
default: {
src: concatFile,
dest: uglifyFile,
options: {
mangle: true,
sourceMap: true
}
}
},
umd: {
all: {
options: {
src: concatFile,
template: __dirname + '/umd.hbs',
objectToExport: '"formlyVanilla"',
version: '<%= pkg.version %>',
contributors: '<%= pkg.contributors.join(\', \') %>'
}
}
}
};
// Pass config to grunt
grunt.initConfig(config);
grunt.registerTask('dev', [
'build',
'connect:dev',
'watch'
]);
grunt.registerTask('build', [
'jshint',
//'mocha',
'clean:tmp',
'copy:build',
'ngtemplates',
'concat',
'ngAnnotate',
'umd:all',
'uglify',
'clean:dist',
'copy:dist'
]);
grunt.registerTask('default', ['build']);
};