Skip to content

Commit

Permalink
first pass at generating style modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lasky committed Aug 31, 2015
1 parent be1562d commit 7174c8c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
35 changes: 35 additions & 0 deletions grunt/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,41 @@ module.exports = function(grunt) {

});

grunt.registerTask('style:imports', function() {
var tasks = [];
var build = grunt.config('build_dir') + "/";
var styles = grunt.file.expand({
cwd: grunt.config('build_dir')
}, 'mm-**/*.css');

var styleData = {};
styles.forEach(function(file) {
var key = file.split(".css").join("").split("/")[0];
if (grunt.file.exists(build + file)) {
var css = grunt.file.read(build + file);
// styleData[key] = css;
grunt.config.set("hogan_static.styles_" + key, {
options:{
data:{
module:key,
style:css
}
},
files:[{
src:'<%= template_dir %>/style_module_template.html',
dest:'<%=build_dir%>/'+key+'/style.html'
}]
});
tasks.push("hogan_static:styles_" + key);
} else {
grunt.log.writeln("Not Found:"+build+file);
}
});

grunt.task.run(tasks);

});

//Create HTML imports for JS library
grunt.registerTask('jslib:imports', function() {
var files = grunt.file.expand({cwd: grunt.config('src_dir') + '/shared/js/' }, '*.js');
Expand Down
12 changes: 12 additions & 0 deletions grunt/templates/style_module_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--
* @license
* Copyright (c) 2015 MediaMath Inc. All rights reserved.
* This code may only be used under the BSD style license found at http://mediamath.github.io/strand/LICENSE.txt
-->
<dom-module id="{{module}}">
<template>
<style>
{{style}}
</style>
</template>
</dom-module>

0 comments on commit 7174c8c

Please sign in to comment.