-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
121 lines (106 loc) · 2.55 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
121
'use strict'
var connect = require('connect')
var serveStatic = require('serve-static')
var srcHtmlDocuments = ['src/**/*.html'];
var BUILD_ENV = process.env.BUILD_ENV || 'production';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-angular-gettext-generate-html')
grunt.loadNpmTasks('grunt-angular-gettext')
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-replace');
grunt.initConfig({
nggettext_extract: {
pot: {
files: {
'src/i18n/po/template.pot': srcHtmlDocuments
}
}
},
replace: {
dist: {
options: {
variables: {
packageJson: require('./package.json'),
BUILD_ENV: BUILD_ENV
}
},
files: [
{expand: true, flatten: false, cwd: 'src/', src: ['**/*.html'], dest: '.tmp/'}
]
}
},
gt_generate_html: {
l10n: {
po: [ 'src/i18n/po/*.po' ],
source: [
{
dest: 'build/{Language}',
options: {
'cwd': '.tmp/'
},
src: ['**/*.html']
}
]
}
},
nggettext_compile: {
all: {
options: {
module: 'dcrweb'
},
files: {
'build/content/js/translations.js': ['i18n/po/*.po']
}
}
},
watch: {
options: {
},
gettext: {
files: [
'src/i18n/po/*.po',
'src/i18n/po/*.pot'
],
tasks: ['gt_generate_html', 'nggettext_compile']
},
assets: {
files: ['src/**/*', 'www-root/content/**'],
tasks: ['default'],
options: {
livereload: true,
},
}
},
connect: {
server: {
options: {
port: 8080,
keepalive: true,
livereload: true,
open: true,
hostname: '*',
base: ['www-root', 'build' ]
}
}
},
copy: {
main: {
files: [
{src: ['src/i18n/languagemap.'+ BUILD_ENV + '.txt'], dest: 'build/languagemap.txt'},
{expand: true, cwd: 'www-root/', src: ['**'], dest: 'build/', dot: true}
],
},
},
clean: ['build', '.tmp']
})
grunt.registerTask('serve', [
'build',
'connect:server',
'watch'
]);
grunt.registerTask('build', ['replace', 'gt_generate_html', 'copy:main'])
grunt.registerTask('default', ['build'])
}