-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.coffee
83 lines (68 loc) · 3.06 KB
/
Gruntfile.coffee
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
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
coffee:
compile:
options:
sourceMap: true
files: [{
expand: true
cwd: 'src/'
src: ['**.coffee']
dest: 'dist/'
rename: (dest, src) ->
filename = "#{src.substring src.lastIndexOf('/'), src.length}"
filename = "#{filename.substring 0, filename.lastIndexOf('.')}"
return "#{dest}#{filename}.js"
}]
# https:#github.com/gruntjs/grunt-contrib-uglify
uglify:
options:
compress: true
preserveComments:'some' # preserve the blocks of comments that start with a /*!
sourceMap: "dist/<%= pkg.name %>.min.js.map"
sourceMapIn: 'dist/<%= pkg.name %>.js.map'
sourceMapRoot: "dist/"
dist:
src:['dist/<%= pkg.name %>.js']
dest:'dist/<%= pkg.name %>.min.js'
# https:#npmjs.org/package/grunt-include-replace
includereplace:
dist:
options:
# Global variables available in all files
globals:
version: '<%= pkg.version %>'
date: '<%= grunt.template.today("yyyy/mm/dd") %>'
earsjs: '<%= pkg.name %>.min.js'
# Optional variable prefix & suffix, defaults as shown
prefix: '@@'
suffix: ''
# Files to perform replacements and includes with
src: ['dist/<%= pkg.name %>.js', 'dist/<%= pkg.name %>.min.js', '*.html']
# Destinaion directory to copy files to
dest: 'dist/'
dev:
options:
# Global variables available in all files
globals:
version: '<%= pkg.version %>'
date: '<%= grunt.template.today("yyyy/mm/dd") %>'
earsjs: '<%= pkg.name %>.js'
# Files to perform replacements and includes with
src: ['dist/<%= pkg.name %>.js', 'dist/<%= pkg.name %>.min.js', '*.html']
yuidoc:
compile:
name: '<%= pkg.name %>'
description: '<%= pkg.description %>'
version: '<%= pkg.version %>'
url: '<%= pkg.homepage %>'
options:
paths: 'dist/'
outdir: 'docs/'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-include-replace'
grunt.loadNpmTasks 'grunt-contrib-yuidoc'
grunt.registerTask 'dev',['coffee:compile','uglify:dist', 'includereplace:dev', 'yuidoc:compile']
grunt.registerTask 'default',['coffee:compile','uglify:dist', 'includereplace:dist', 'yuidoc:compile']