forked from vtex/front.phone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
103 lines (89 loc) · 3.19 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
GruntVTEX = require 'grunt-vtex'
webpack = require 'webpack'
module.exports = (grunt) ->
pkg = grunt.file.readJSON 'package.json'
# Parts of the index we wish to replace on deploy
replaceMap = {}
replaceMap[pkg.paths[0] + '/'] = "/"
replaceMap['{version}'] = pkg.version
devReplaceMap = {}
devReplaceMap['{version}'] = "#{pkg.version}"
defaultConfig = GruntVTEX.generateConfig grunt, pkg,
followHttps: true
replaceMap: replaceMap
devReplaceMap: devReplaceMap
livereload: !grunt.option('no-lr')
open: false
copyIgnore: ['!script/**/*.js', '!script/{countries}']
webpackPlugins = [
new webpack.BannerPlugin('front-phone - v'+pkg.version+' - https://vtex.github.io/front.phone/', {entryOnly: true})
new webpack.optimize.UglifyJsPlugin({compress: { warnings: false }}),
]
# Add custom configuration here as needed
customConfig =
publicPath: "/<%= relativePath %>"
concat:
templates: {}
mochaTest:
main:
options:
reporter: 'spec'
src: ['spec/**/*-spec.coffee']
'gh-pages':
options:
base: 'build/<%= relativePath %>'
src: ['**']
coffee:
dist:
files: [
expand: true
cwd: 'src/script'
src: ['**/*.coffee', '!**/main.coffee']
dest: "./"
rename: (path, filename) ->
path + filename.replace("coffee", "js")
]
watch:
coffee:
files: ['src/script/**/*.coffee']
tasks: ['coffee:main']
main:
tasks: ['webpack:main', 'copy:main', 'copy:dev']
webpack:
options:
module:
loaders: [
{ test: /\.coffee$/, loader: "coffee-loader", exclude: /node_modules/ }
{ test: /\.less$/, loader: "style!css!less", exclude: /node_modules/ }
{ test: /\.png$/, loader: "url-loader?limit=100000", exclude: /node_modules/ }
{ test: /\.jpg$/, loader: "file-loader", exclude: /node_modules/ }
]
# devtool: "eval"
main:
entry:
"main": "./src/script/main.coffee"
"phone-all-bundle": "./src/script/phone-all-countries.coffee"
"phone-filter": "./src/script/phone-filter.coffee"
output:
path: "build/<%= relativePath %>/script/"
publicPath: "<%= publicPath %>/script/"
filename: "[name].js"
plugins: webpackPlugins
resolve:
modulesDirectories: ["src/script/"]
extensions: ["", ".js", ".coffee"]
tasks =
# Building block tasks
build: ['clean', 'webpack:main', 'copy:main', 'copy:dev', 'copy:pkg']
test: ['mochaTest']
# Deploy tasks
dist: ['build', 'mochaTest', 'coffee:dist', 'copy:deploy'] # Dist
publish: ['build', 'mochaTest', 'gh-pages'] # Publish to Github Pages
# Development tasks
dev: ['nolr', 'build', 'mochaTest', 'watch']
default: ['build', 'connect', 'mochaTest', 'watch']
# Project configuration.
grunt.config.init defaultConfig
grunt.config.merge customConfig
grunt.loadNpmTasks name for name of pkg.devDependencies when name[0..5] is 'grunt-' and name isnt 'grunt-vtex' and name isnt 'grunt-cli'
grunt.registerTask taskName, taskArray for taskName, taskArray of tasks