mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
0c86241c5b
* webpack poc, this is not going to work for plugins, dam * tech: webpack and systemjs for plugins starting to work * tech: webpack and systemjs combo starting to work * tech: webpack + karma tests progress * tech: webpack + karma progress * tech: working on tests * tech: webpack * tech: webpack + karma, all tests pass * tech: webpack + karma, all tests pass * tech: webpack all tests pass * webpack: getting closer * tech: webpack progress * webpack: further build refinements * webpack: ng annotate fixes * webpack: optimized build fix * tech: minor fix for elasticsearch * tech: webpack + ace editor * tech: restored lodash move mixin compatability * tech: added enzyme react test and upgraded to react v16 * tech: package version fix * tech: added testdata to built in bundle * webpack: sass progress * tech: prod & dev build is working for the sass * tech: clean up unused grunt stuff and moved to scripts folder * tech: added vendor and manifest chunks, updated readme and docs * tech: webpack finishing touches
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
module.exports = function(grunt) {
|
|
"use strict";
|
|
|
|
function escapeRegExp(str) {
|
|
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
}
|
|
|
|
function extractColour(line) {
|
|
var regex = /\s*:\s*(#[a-fA-F0-9]{3,6})\s*(!default|!default;)?/;
|
|
var matches = line.match(regex);
|
|
return matches ? matches[1] : matches;
|
|
}
|
|
|
|
function extractVariable(line) {
|
|
var matches = line.match(/(\$[0-9a-zA-Z_-]+)\s*(!default|!default;)?/)
|
|
return matches ? matches[1] : matches
|
|
}
|
|
|
|
function readVars(file, obj) {
|
|
var content = grunt.file.read(file);
|
|
var lines = content.split('\n');
|
|
|
|
lines.forEach(function(line) {
|
|
var variable = extractVariable(line);
|
|
if (variable) {
|
|
var color = extractColour(line, variable);
|
|
if (color) {
|
|
obj[variable] = color;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
grunt.registerTask('styleguide', function() {
|
|
var data = {
|
|
dark: {}, light: {}
|
|
};
|
|
|
|
readVars('public/sass/_variables.dark.scss', data.dark);
|
|
readVars('public/sass/_variables.light.scss', data.light);
|
|
|
|
var styleGuideJson = grunt.config().srcDir + '/build/styleguide.json';
|
|
grunt.file.write(styleGuideJson, JSON.stringify(data, null, 4));
|
|
|
|
});
|
|
|
|
};
|