update plugin name
This commit is contained in:
+4
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* grunt-base64
|
||||
* https://github.com/ceee/grunt-base64
|
||||
* grunt-datauri
|
||||
* https://github.com/ceee/grunt-datauri
|
||||
*
|
||||
* Copyright (c) 2013 Tobias Klika
|
||||
* Licensed under the MIT license.
|
||||
@@ -31,7 +31,7 @@ module.exports = function (grunt) {
|
||||
},
|
||||
|
||||
// Configuration to be run (and then tested).
|
||||
base64: {
|
||||
datauri: {
|
||||
default: {
|
||||
options: {
|
||||
test: true
|
||||
@@ -58,5 +58,5 @@ module.exports = function (grunt) {
|
||||
|
||||
grunt.registerTask('test', [ 'clean', 'mkdir:tmp', 'nodeunit', 'clean' ]);
|
||||
|
||||
grunt.registerTask('default', [ 'test', 'base64' ]);
|
||||
grunt.registerTask('default', [ 'test', 'datauri' ]);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# grunt-base64
|
||||
# grunt-datauri
|
||||
|
||||
> create base64 encoded data-uris for css from images
|
||||
|
||||
@@ -10,17 +10,17 @@ This plugin requires Grunt `~0.4.0`
|
||||
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
|
||||
|
||||
```shell
|
||||
npm install grunt-base64 --save-dev
|
||||
npm install grunt-datauri --save-dev
|
||||
```
|
||||
|
||||
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
|
||||
|
||||
```js
|
||||
grunt.loadNpmTasks('grunt-base64');
|
||||
grunt.loadNpmTasks('grunt-datauri');
|
||||
```
|
||||
|
||||
## Release History
|
||||
* 2013-05-15 v0.1.0 please wait :P
|
||||
* 2013-05-15 v0.1.0 basic functionality
|
||||
|
||||
|
||||
## Contributors
|
||||
|
||||
+5
-5
@@ -1,23 +1,23 @@
|
||||
{
|
||||
"name": "grunt-base64",
|
||||
"name": "grunt-datauri",
|
||||
"description": "create base64 encoded data-uris for css from images",
|
||||
"version": "0.1.0",
|
||||
"homepage": "https://github.com/ceee/grunt-base64",
|
||||
"homepage": "https://github.com/ceee/grunt-datauri",
|
||||
"author": {
|
||||
"name": "Tobias Klika",
|
||||
"url": "http://ceecore.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/ceee/grunt-base64.git"
|
||||
"url": "git://github.com/ceee/grunt-datauri.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ceee/grunt-base64/issues"
|
||||
"url": "https://github.com/ceee/grunt-datauri/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/ceee/grunt-base64/blob/master/LICENSE-MIT"
|
||||
"url": "https://github.com/ceee/grunt-datauri/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"main": "Gruntfile.js",
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* grunt-datauri
|
||||
* https://github.com/ceee/grunt-datauri
|
||||
*
|
||||
* Copyright (c) 2013 Tobias Klika
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function (grunt)
|
||||
{
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var childProcess = require('child_process');
|
||||
var filesize = require('filesize');
|
||||
var datauri = require('datauri');
|
||||
|
||||
grunt.registerMultiTask('datauri', 'create base64 encoded data-uris for css from images', function ()
|
||||
{
|
||||
var options = this.options({
|
||||
|
||||
});
|
||||
|
||||
|
||||
this.files.forEach(function(f)
|
||||
{
|
||||
// filter valid files and map data uri generation
|
||||
var data = f.src.filter( fileExists ).map( generateDataUri ).join('\n');
|
||||
|
||||
// Write the destination file.
|
||||
grunt.file.write(f.dest, data);
|
||||
|
||||
grunt.log.writeln('File "' + f.dest + '" created.');
|
||||
});
|
||||
|
||||
|
||||
// generates a datauri object from file
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
function generateDataUri( filepath )
|
||||
{
|
||||
var dataObj = new datauri( filepath );
|
||||
|
||||
return dataObj.getCss();
|
||||
}
|
||||
|
||||
|
||||
// Warn on and remove invalid source files (if nonull was set).
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
function fileExists( filepath )
|
||||
{
|
||||
if (!grunt.file.exists(filepath))
|
||||
{
|
||||
grunt.log.warn('source file "' + filepath + '" not found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var grunt = require('grunt');
|
||||
var fs = require('fs');
|
||||
|
||||
exports.datauri = {
|
||||
|
||||
setUp: function( done )
|
||||
{
|
||||
done();
|
||||
},
|
||||
|
||||
datauri_options: function( test )
|
||||
{
|
||||
test.expect( 1 );
|
||||
test.equal( 1, 1, "random..." );
|
||||
test.done();
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user