-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AMC:UI:Build adding a front end Grunt build system
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
module.exports = function(grunt) { | ||
grunt.initConfig({ | ||
// pull in all of the dependencies of setup.js into one file | ||
requirejs: { | ||
compile: { | ||
options: { | ||
appDir: 'static', | ||
baseUrl: './js', | ||
dir: 'build/static', | ||
optimize: 'none', | ||
mainConfigFile: 'static/js/setup.js', | ||
modules: [{ | ||
name: 'setup', | ||
}] | ||
} | ||
}, | ||
}, | ||
|
||
// revision setup.js and css files based on content | ||
filerev: { | ||
options: { | ||
algorithm: 'md5', | ||
length: 8 | ||
}, | ||
js: { | ||
src: 'build/static/js/setup.js', | ||
}, | ||
css: { | ||
src: 'build/static/css/*.css', | ||
}, | ||
}, | ||
|
||
// replace filenames with revisioned file names | ||
filerev_replace: { | ||
options: { | ||
assets_root: 'build', | ||
}, | ||
html: { | ||
src: 'build/static/index.html', | ||
}, | ||
}, | ||
|
||
// filerev_replace does not replace data-main argument supplied to | ||
// requirejs, doing that here | ||
replace: { | ||
requirejs: { | ||
src: 'build/static/index.html', | ||
overwrite: true, | ||
replacements: [{ | ||
// 1. replace data-main with the revisioned file name | ||
from: 'static/js/setup', | ||
to: function(match) { | ||
var k, v; | ||
for(k in grunt.filerev.summary) { | ||
v = grunt.filerev.summary[k]; | ||
if(k.indexOf('static/js/setup') !== -1) { | ||
// remove prefix 'build/' and suffix '.js' | ||
return v.slice('build/'.length, -1*'.js'.length); | ||
} | ||
} | ||
return match; | ||
} | ||
}], | ||
}, | ||
}, | ||
|
||
}); | ||
|
||
// load modules | ||
grunt.loadNpmTasks('grunt-contrib-requirejs'); | ||
grunt.loadNpmTasks('grunt-filerev'); | ||
grunt.loadNpmTasks('grunt-filerev-replace'); | ||
grunt.loadNpmTasks('grunt-text-replace'); | ||
|
||
grunt.registerTask('default', ['requirejs', 'filerev', 'filerev_replace', 'replace']); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "amc", | ||
"version": "3.7.0", | ||
"description": "AMC client integrated with the new go server", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "tejas@aerospike.com", | ||
"license": "AGPLv3", | ||
"devDependencies": { | ||
"grunt": "^1.0.1", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-requirejs": "^1.0.0", | ||
"grunt-filerev": "^2.3.1", | ||
"grunt-filerev-replace": "^0.1.5", | ||
"grunt-text-replace": "^0.4.0", | ||
"requirejs": "^2.3.2" | ||
} | ||
} |