forked from jjprogramsllc/practical-form.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
115 lines (99 loc) · 2.91 KB
/
Copy pathGruntfile.js
File metadata and controls
115 lines (99 loc) · 2.91 KB
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
/* globals require, module */
var path = require('path');
var moduleName = 'jjp.practical-forms';
module.exports = function(grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
build: {
tasks: ['buildAll'],
packageConfig: 'pkg',
packages: '*.json',
gitAdd: '--all'
},
replace: {
build: {
src: 'src/practical-forms.js',
dest: 'src/practical-forms.js',
replacements: [{
from: /VERSION\s=\s['\d\.]+;/, // string replacement
to: 'VERSION = \'<%= pkg.version %>\';'
}]
}
},
clean: ['.tmp', 'dist'],
jshint: {
options: { 'jshintrc': true},
all: ['Gruntfile.js', 'src/**/*.js']
},
uglify: {
build: {
src: ['src/practical-forms.js', 'src/components/**/*.js', 'src/forms/**/*.js'],
dest: '.tmp/<%= pkg.name %>.min.js'
}
},
html2js: {
options: {
module: moduleName + '.templates',
singleModule: true,
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true, // Only if you don't use comment directives!
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
},
rename: function(filename) {
return '/jjp/pf/' + path.basename(filename);
},
},
build: {
src: ['src/components/**/*.html', 'src/forms/**/*.html'],
dest: '.tmp/<%= pkg.name %>.tpl.min.js',
},
},
concat: {
options: {
banner: '/*! <%= pkg.name %> v<%= pkg.version %> | (c) <%=grunt.template.today("yyyy") %>, <%= pkg.author %> | Distributed under the <%= pkg.license %> License */\n',
},
build: {
files: [{
src: ['<%= html2js.build.dest %>', 'src/practical-forms.js', 'src/components/**/*.js', 'src/forms/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}]
},
prod: {
files: [{
src: ['<%= html2js.build.dest %>', '<%= uglify.build.dest %>'],
dest: 'dist/<%= pkg.name %>.min.js'
}]
},
},
'http-server': {
dev: {
root: './',
port: 8282,
host: '0.0.0.0',
showDir: true,
autoIndex: true,
ext: 'html',
// run in parallel with other tasks
runInBackground: true,
}
},
watch: {
build: {
files: ['Gruntfile.js', 'src/**/*.js', 'src/**/*.html'],
tasks: ['buildAll'],
},
}
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('default', ['buildAll']);
grunt.registerTask('buildAll', ['clean', 'replace','jshint', 'uglify', 'html2js', 'concat']);
grunt.registerTask('dev', ['buildAll', 'http-server', 'watch']);
};