You've already forked sass-spritemaker
Bunch of tweaks and fixes.
This commit is contained in:
@@ -27,7 +27,7 @@ $sprite: (
|
||||
);
|
||||
|
||||
@mixin use-sprite($name) {
|
||||
background: transparent '{{& url}}' no-repeat;
|
||||
background: transparent url('{{& url}}') no-repeat;
|
||||
background-position: map-get($sprite, $name);
|
||||
background-size: {{bounds.width}}px {{bounds.height}}px;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2019-present Tomek Wójcik <contact@bthlabs.pl>
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@@ -87,8 +87,8 @@ const spritemaker = (options) => {
|
||||
const hash = crypto.Hash('md5');
|
||||
hash.update(outputImage.data);
|
||||
|
||||
const outputBasename = `sprite-${hash.digest('hex')}`;
|
||||
const outputName = `${outputBasename}.png`;
|
||||
const outputBasename = `sprite`;
|
||||
const outputName = `${outputBasename}-${hash.digest('hex')}.png`;
|
||||
const outbutBuffer = PNG.sync.write(outputImage, {
|
||||
colorType: 6
|
||||
});
|
||||
@@ -99,16 +99,19 @@ const spritemaker = (options) => {
|
||||
const template = fs.readFileSync(
|
||||
path.resolve(__dirname, 'scss.mustache'), {encoding: 'utf-8'}
|
||||
);
|
||||
const outputURL = new URI(options.urlPrefix).path('/' + outputName);
|
||||
const context = {
|
||||
bounds: bounds,
|
||||
images: spriteMap,
|
||||
url: outputURL.href()
|
||||
url: path.join(options.urlPrefix, outputName)
|
||||
};
|
||||
const scss = Mustache.render(template, context);
|
||||
|
||||
const scssName = `${outputBasename}.scss`;
|
||||
fs.writeFileSync(
|
||||
path.resolve(options.output, `${outputBasename}.scss`), scss
|
||||
path.resolve(options.output, scssName), scss
|
||||
);
|
||||
|
||||
return [outputName, scssName];
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user