-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
79 lines (77 loc) · 2.45 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
// Wrapper function to encapsulate Grunt config
module.exports = function(grunt) {
// Initialize our Grunt config object
grunt.initConfig({
bowercopy: {
options: {
runBower: false,
report: false,
srcPrefix: 'bower_components'
},
gem_vendor: {
options: {
destPrefix: 'concerto-frontend-gem/vendor/assets/javascripts'
},
files: {
'moment.min.js': 'moment/min/moment.min.js',
'moment-timezone-with-data.min.js': 'moment-timezone/builds/moment-timezone-with-data.min.js',
'webcomponents-lite.min.js': 'webcomponentsjs/webcomponents-lite.min.js'
}
}
},
"regex-replace": {
componentize: {
src: ['concerto-frontend-gem/app/assets/html/concerto_frontend/concerto-frontend.html'],
actions: [
{
name: 'stripstart',
search: /^((?:\s|.)*?)(<script>)/,
replace: '$2',
flags: ''
},
{
name: 'stripvulcan',
search: '(</head.*?>)(<dom-module)',
replace: '$2',
flags: ''
},
{
name: 'stripend',
search: '(</dom-module>)(.*?</html>)',
replace: '$1',
flags: ''
}
]
}
},
// Read NPM package settings and store values in pkg property
pkg: grunt.file.readJSON("package.json"),
// Configure the vulcanize plugin to concatenate our Polymer html files
vulcanize: {
default: {
options: {
inlineScripts: true,
inlineCss: true,
stripComments: true
},
files: {
"concerto-frontend-gem/app/assets/html/concerto_frontend/concerto-frontend.html" : "vulcanize_this.html"
},
},
},
watch: {
scripts: {
files: ['*.html', 'contents/*.html'],
tasks: ['vulcanize', 'regex-replace']
},
},
});
// Load in the Grunt plugins that will be used
// these should be installed via 'npm install' before running 'grunt'
grunt.loadNpmTasks('grunt-vulcanize'); // concatenate Polymer elements
grunt.loadNpmTasks('grunt-contrib-watch'); // run tasks when files are modified
grunt.loadNpmTasks('grunt-bowercopy'); // copy files to gem
grunt.loadNpmTasks('grunt-regex-replace');
// Set up our default task that is run when 'grunt' is executed
grunt.registerTask('default', ['vulcanize', 'regex-replace', 'bowercopy']);
}