forked from alanshaw/david-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·120 lines (103 loc) · 3.12 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
module.exports = function(grunt) {
grunt.initConfig({
conf: require("./config"),
pkg: grunt.file.readJSON("package.json"),
// Copy files that don"t need compilation to dist/
copy: {
dist: {
files: [
// Copy all (non hidden) files (not directories) from src
{dest: "dist/", src: ["*", "!LICENSE.md"], filter: "isFile", expand: true, cwd: "public/"},
// Copy any JavaScript libs
{dest: "dist/", src: "js/vendor/*.min.js", expand: true, cwd: "public/"},
// Copy other resources
{dest: "dist/", src: "fonts/**", expand: true, cwd: "public/"},
{dest: "dist/", src: "img/**", expand: true, cwd: "public/"}
]
}
},
includereplace: {
dist: {
options: {
globals: {
version: "<%= pkg.version %>",
headHtml: "",
hostname: "<%= conf.site.hostname %>",
npmsite: "<%= conf.npm.hostname %>",
githubsite: "<%= conf.github.protocol %>://<%= conf.github.host %>"
}
},
files: [
{src: "*.html", dest: "dist/", expand: true, cwd: "public/"},
{src: "inc/*.html", dest: "dist/", expand: true, cwd: "public/"}
]
}
},
less: {
compile: {
files: {
"dist/css/main-<%= pkg.version %>.css": "public/css/main.less"
}
}
},
cssmin: {
minify: {
options: {
compatibility: "ie9",
keepSpecialComments: 0
},
files: {
"dist/css/main-<%= pkg.version %>.css": "dist/css/main-<%= pkg.version %>.css"
}
}
},
browserify: {
dist: {
files: {"dist/js/bundle-<%= pkg.version %>.js": "public/js/main.js"},
options: {transform: ["brfs"]}
}
},
// Minify the site script
uglify: {
options: {
compress: {
warnings: false
},
mangle: true,
preserveComments: false,
report: "min"
},
compress: {
src: "dist/js/bundle-<%= pkg.version %>.js",
dest: "dist/js/bundle-<%= pkg.version %>.js"
}
},
// Lint the server JavaScript
jshint: {
files: ["*.js", "public/js/*.js", "!public/js/plugins.js", "test/*.js"],
options: {
jshintrc: ".jshintrc"
}
},
// Test the things
nodeunit: {
all: ["test/**/*_test.js"]
},
// Watch JS, LESS, HTML and image files for changes, copy & compile but not minify for easy debug during dev
watch: {
project: {
options: {atBegin: true},
files: ["public/js/**/*.js", "public/css/**/*.less", "public/**/*.html", "public/img/**/*"],
tasks: ["copy", "includereplace", "less:compile", "browserify"]
}
},
clean: {
dist: "dist/*"
}
})
// Load any grunt plugins found in package.json.
require("load-grunt-tasks")(grunt, {scope: "devDependencies"});
grunt.registerTask("base", ["jshint", "nodeunit", "copy", "includereplace", "less:compile", "browserify"])
grunt.registerTask("min", ["cssmin", "uglify"])
grunt.registerTask("default", ["base", "min"])
}