GithubHelp home page GithubHelp logo

grunt-zopfli-native's Introduction

grunt-zopfli-native Linux Build Status Dependency Status devDependency Status

Compress your files with zopfli without installing anything.

Installing

npm install grunt-zopfli-native --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-zopfli-native');

Using

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

mode String

Choose an output format, you can choose between gzip, zlib or deflate. Defaults to gzip.

zopfli({ mode: 'zlib' })

extension String

Forces an extension to your files. Defaults depends on the mode chosen.

zopfli({ extension: '.gzip' })

Providing an empty string will disable adding an extension (eg. preventing '.gz' being added when gzip mode is used).

limit Number

Limit on the number of files compressed in parallel. Defaults to the number of CPUs on the host (as per the os module).

Setting this limit greater than UV_THREADPOOL_SIZE (defaults to 4) won't really work as desired. Increasing UV_THREADPOOL_SIZE is a good idea if needed. (e.g. UV_THREADPOOL_SIZE=10 grunt zopfli)

zopfli({ limit: 1 })

zopfliOptions Object

Options object to pass through to node-zopfli. See node-zopfli documentation for more information.

{
  verbose: false,
  verbose_more: false,
  numiterations: 15,
  blocksplitting: true,
  blocksplittinglast: false,
  blocksplittingmax: 15
};

Examples

Make a gzip file

zopfli: {
  main: {
    files: [{
      src: ['path/*'],
      dest: 'gzipped_files/',
      filter: 'isFile'
    }]
  }
}

Compress your files for production

zopfli: {
  main: {
    expand: true,
    cwd: 'assets/',
    src: ['**/*'],
    dest: 'public/'
  }
}

Gzip files and preserve filenames

zopfli: {
  main: {
    files: [{
      expand: true,
      cwd: 'build/',
      src: ['*.{png,jpg,js}'],
      dest: 'build/compressed/'
    }],
    options: {
      extension: ''
    }
  }
}

grunt-zopfli-native's People

Contributors

bprodoehl avatar mobilemind avatar perry-mitchell avatar pierreinglebert avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grunt-zopfli-native's Issues

Nginx gzip static support

Add an option to set the same modified timestamp on gzipped file & raw in order to make gzip static work.

Use `chalk` instead of `colors`

Grunt is moving away from using the implicit colors module on the String.prototype (eg 'string'.green) as it clutters the prototype for everyone and is generally magic and bad.

Use chalk explicitly instead (example).

under grunt 1.0.1 zopfli Task fails due to- Warning: grunt.util._.include is not a function...

This is due to Grunt updating to lodash 4.3.0 which removed the alias _.include in favor of _.includes in 4.0.0. (grunt.util._ is deprecated and should most likely not be used anyway- the recommended solution is use lodash directly)

See a similar issue #177 , Task fails due to Warning: grunt.util._.include is not a function for grunt-contrib-compress

The issue cited above has more details to help you resolve this. I don't know how to due that myself or I'd change something myself make a pull request.

Please update grunt-zopfli-native if you can, I use your module and appreciate it. Thank you.

can't compress files larger than 64KB

Trying to compress a file larger than 64KB results in a gz file that can't be unzipped with gunzip and appears truncated (at 65,535 bytes) in browsers. I am seeing this with the latest version of both grunt-contrib-zopfli and grunt-zopfli-native, on 64-bit Fedora and CentOS 6.5.

I have created a minimal project that demonstrates this, and I can share that if you wish, but it may be easier to just say what it does. I have some big files generated with "openssl rand -base64 400000 > bigfile.dat", and then I try to compress that in a Gruntfile with this block:

    zopfli: {
      main: {
        expand: true,
        src: ['files/*'],
        dest: 'output/'
      }
    }

The result is a file that is about the same size as the output of the zopfli command-line utility, but which can't be unzipped with gunzip. Here is the output of gunzip:

gzip: bigfile.dat.gz: invalid compressed data--crc error
gzip: bigfile.dat.gz: invalid compressed data--length error

Files under the 64KB mark work just fine.

Why?

Why did you feel the need to create this, given that there’s been a grunt-zopfli task for ages? There don’t seem to be any important differences in functionality between the two. What am I missing? Just wondering.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.