Skip to content

Commit

Permalink
AMC:UI:Build adding a front end Grunt build system
Browse files Browse the repository at this point in the history
  • Loading branch information
tejassp committed Nov 30, 2016
1 parent 69a5fc6 commit 774683a
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
77 changes: 77 additions & 0 deletions Gruntfile.js
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']);
}

19 changes: 19 additions & 0 deletions package.json
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"
}
}

0 comments on commit 774683a

Please sign in to comment.