bosonic.js
1.15 KB
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
/*
* grunt-bosonic
* https://github.com/bosonic/grunt-bosonic
*
* Copyright (c) 2013 Raphaël Rougeron
* Licensed under the MIT license.
*/
'use strict';
var path = require('path'),
transpiler = require('bosonic-transpiler');
module.exports = function(grunt) {
grunt.registerMultiTask('bosonic', 'A Grunt task that transpiles to-the-spec Web Components into polyfilled JavaScript', function() {
var css = [], js = [];
this.filesSrc.forEach(function(filepath) {
var fileDir = path.dirname(filepath),
transpiled = transpiler.transpile(grunt.file.read(filepath));
transpiled.stylesheets.forEach(function(href) {
css.push(grunt.file.read(fileDir + '/' + href));
});
css.push(transpiled.css);
transpiled.scripts.forEach(function(src) {
js.push(grunt.file.read(fileDir + '/' + src));
});
js.push(transpiled.js);
});
var jsFile = this.data.js,
cssFile = this.data.css;
grunt.file.write(jsFile, js.join("\n"));
grunt.file.write(cssFile, css.join("\n"));
});
}