Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use options:hashFunction? #2

Open
wxwxnzm opened this issue Feb 5, 2018 · 3 comments
Open

how to use options:hashFunction? #2

wxwxnzm opened this issue Feb 5, 2018 · 3 comments

Comments

@wxwxnzm
Copy link

wxwxnzm commented Feb 5, 2018

I tried to time imgPath and imgName,like this
sprotesmith({ imgName: 'a_icon.png' + (+new Date()), imgPath: '/img/a_icon.png' + (+new Date()) })
gulp will change the file name every time ,
so i tried:
sprotesmith({ imgName: 'a_icon.png', imgPath: '/img/a_icon.png', hashFunction(f, c) { return f + '_17点19分‘; } })
it didn't work

Is it possible to generate different hash values each time depending on the picture?

@Romanx
Copy link
Contributor

Romanx commented Feb 10, 2018

Hi there, by default if you don't provide a hash function spritesmash will use the MD5 on the contents of the file to determine the hash making it stable based on the contents of the file. Is that what you're after?

@brunis
Copy link

brunis commented Apr 28, 2020

I tried to time imgPath and imgName,like this
sprotesmith({ imgName: 'a_icon.png' + (+new Date()), imgPath: '/img/a_icon.png' + (+new Date()) })
gulp will change the file name every time ,
so i tried:
sprotesmith({ imgName: 'a_icon.png', imgPath: '/img/a_icon.png', hashFunction(f, c) { return f + '_17点19分‘; } })
it didn't work

Is it possible to generate different hash values each time depending on the picture?

You misspelled spritesmith and this project is spritesmash, not smith.

@brunis
Copy link

brunis commented Apr 28, 2020

gulp.task('default', function () {
    return gulp.src('src/images/*.{png}')
    .pipe(spritesmith({
      imgName: 'sprite.png',
      cssName: 'sprite.css',
    }))
    .pipe(spritesmash({
"hashFunction" : "SHA1" // or MD5 (default) or timestamp
}))
    .pipe(gulp.dest('dist'));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants