-
Notifications
You must be signed in to change notification settings - Fork 13
/
Gruntfile.coffee
111 lines (110 loc) · 3.64 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
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
#spawn = require('child_process').spawn
#require("load-grunt-tasks")(grunt)
module.exports = (grunt) ->
# Gruntfile
# https://github.com/sindresorhus/grunt-shell
grunt.loadNpmTasks("grunt-shell")
# https://www.npmjs.com/package/grunt-contrib-coffee
grunt.loadNpmTasks("grunt-contrib-coffee")
# https://github.com/gruntjs/grunt-contrib-watch
grunt.loadNpmTasks("grunt-contrib-watch")
grunt.loadNpmTasks("grunt-contrib-uglify")
grunt.loadNpmTasks("grunt-contrib-cssmin")
# Validators
grunt.loadNpmTasks('grunt-bootlint')
grunt.loadNpmTasks('grunt-html')
grunt.loadNpmTasks('grunt-string-replace')
grunt.loadNpmTasks('grunt-postcss')
grunt.loadNpmTasks('grunt-contrib-less')
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
shell:
options:
stderr: false
execOptions:
maxBuffer: 1048576
test:
command: "echo test"
movesrc:
command: ["mv js/c.src.coffee js/maps/c.src.coffee"].join("&&")
cpsearch:
command: ["cp -r node_modules/simple-jekyll-search/dest bower_components/simple-jekyll-search"].join("&&")
vulcanize:
# Should also use a command to replace js as per uglify:vulcanize
command: ["vulcanize --strip-comments --inline-scripts pre-vulcanize.html --out-html vulcanized.html"].join("&&")
regex_extract:
default_options:
options:
regex: "<div[^>]*by-vulcanize[^>]*><script>[\\s\\S]*<\\/script>\\s*<\\/dom-module>\\s*<\\/div>"
modifiers: "mig"
includePath: false
matchPoints: "0"
files:
"vulcanized-div-and-dom-module.html": ["vulcanized.html"]
clean: ["vulcanized.html", "vulcanized-parsed.html", "post-vulcanize.html"]
min:
dist:
src:['js/c.js']
dest:'js/c.min.js'
cssmin:
options:
sourceMap: true
advanced: false
target:
files:
"style.min.css":["style.css"]
uglify:
dist:
options:
sourceMap:true
sourceMapName:"js/maps/c.map"
sourceMapIncludeSources:true
sourceMapIn:"coffee/maps/c.js.map"
compress:
# From https://github.com/mishoo/UglifyJS2#compressor-options
dead_code: true
unsafe: true
conditionals: true
unused: true
loops: true
if_return: true
drop_console: false # Production! Change to false in dev
warnings: true
properties: true
sequences: true
cascade: true
files:
"js/c.min.js":["js/c.js"]
coffee:
compile:
options:
bare: false
join: true
sourceMapDir: "coffee/maps"
sourceMap: true
files:
"js/c.js":"coffee/*.coffee"
less:
# https://github.com/gruntjs/grunt-contrib-less
options:
sourceMap: true
outputSourceFiles: true
files:
dest: "style.css"
src: ["less/style.less"]
postcss:
options:
processors: [
require('autoprefixer')({browsers: 'last 1 version'})
]
dist:
src: "style.css"
watch:
scripts:
files: ["coffee/*.coffee"]
tasks: ["coffee:compile","uglify:dist"]
# Now the tasks
grunt.registerTask("default",["watch"])
grunt.registerTask("vulcanize","Vulcanize web components",["shell:vulcanize","regex_extract","clean"])
grunt.registerTask("compile","Compile coffeescript",["coffee:compile", "shell:movesrc","uglify:dist","shell:cpsearch"])
grunt.registerTask("compileNoUglify","Compile coffeescript",["coffee:compile","shell:movesrc","shell:cpsearch"])