-
Notifications
You must be signed in to change notification settings - Fork 50
/
Gruntfile.coffee
66 lines (56 loc) · 1.7 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
GruntVTEX = require 'grunt-vtex'
module.exports = (grunt) ->
pkg = grunt.file.readJSON 'package.json'
replaceMap = {}
config = GruntVTEX.generateConfig grunt, pkg,
replaceMap: replaceMap
config.coffee.main.files = [
expand: true
cwd: 'src'
src: ['**/*.coffee']
dest: "build/<%= relativePath %>/"
rename: (path, filename) ->
path + filename.replace("coffee", "js")
]
config.concat =
main:
files:
'build/<%=relativePath%>/vtex.js': [
'build/<%= relativePath %>/extended-ajax.js'
'build/<%= relativePath %>/catalog.js'
'build/<%= relativePath %>/checkout.js'
]
config.uglify =
main:
files: [
expand: true
cwd: 'build/<%=relativePath%>/'
src: '*.js'
dest: 'build/<%=relativePath%>/'
rename: (dest, src) -> dest + '/' + src.replace('.js', '.min.js')
]
options:
sourceMap: true
config.copy.latest =
files: [
expand: true
cwd: "build/<%= relativePath %>/"
src: ['**']
dest: "#{pkg.deploy}/latest"
]
config.watch.coffee.files = ['src/*.coffee']
tasks =
# Building block tasks
build: ['clean', 'copy:pkg', 'coffee', 'concat']
min: ['uglify'] # minifies files
# Deploy tasks
dist: ['build', 'min', 'copy:deploy', 'copy:latest'] # Dist - minifies files
test: []
vtex_deploy: ['shell:cp']
# Development tasks
dev: ['nolr', 'build', 'min', 'watch']
default: ['dev']
# Project configuration.
grunt.initConfig config
grunt.loadNpmTasks name for name of pkg.devDependencies when name[0..5] is 'grunt-' and name isnt 'grunt-vtex'
grunt.registerTask taskName, taskArray for taskName, taskArray of tasks