GithubHelp home page GithubHelp logo

barneyb / digest-brunch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mutewinter/digest-brunch

0.0 3.0 0.0 90 KB

Unsupported: A Brunch plugin that appends a unique SHA digest to asset filenames.

Home Page: https://www.npmjs.org/package/digest-brunch

License: MIT License

CoffeeScript 100.00%

digest-brunch's Introduction

Unsupported Project Status: Unsupported - The project has reached a stable, usable state but the author(s) have ceased all work on it.

I am no longer maintaining digest-brunch. I switched to Webpack for my front end applications. Contact me (@mutewinter) if you'd like to take over support for digest-brunch.

digest-brunch

A Brunch plugin that appends a unique SHA digest to asset filenames. Allows for far-future caching of assets.

Note: digest-brunch is not compatible with gzip-brunch.

Usage

npm install --save digest-brunch

Identify assets that you want to be digested with DIGEST(filename.ext), or a custom pattern of your choosing.

<!DOCTYPE html>
<html lang="en">
<head>
  <script src="DIGEST(test.js)"></script>
  <link rel="stylesheet" href="DIGEST(test.css)">
</head>
<body>
  <script src="DIGEST(js/nested.js)"></script>
</body>
</html>

Run brunch build --production and you'll see something like the following:

Note: digest-brunch can not be run in watch mode. It's only intended for production builds, run once.

<!DOCTYPE html>
<html lang="en">
<head>
  <script src="test-75570c26.js"></script>
  <link rel="stylesheet" href="test-e3eda643.css">
</head>
<body>
  <script src="js/nested-4df52a0a.js"></script>
</body>
</html>

The asset files are also renamed, inside the public folder, to match the names above.

Options

Optional You can override digest-brunch's default options by updating your config.coffee with overrides.

These are the default settings:

exports.config =
  # ...
  plugins:
    digest:
      # A RegExp where the first subgroup matches the filename to be replaced
      pattern: /DIGEST\(\/?([^\)]*)\)/g
      # After replacing the filename, should we discard the non-filename parts of the pattern?
      discardNonFilenamePatternParts: yes
      # RegExp that matches files that contain DIGEST references.
      referenceFiles: /\.html$/
      # How many digits of the SHA1 to append to digested files.
      precision: 8
      # Force digest-brunch to run in all environments when true.
      alwaysRun: false
      # Specify an array of environments to run in.
      environments: ['production']
      # Prepend an asset host URL to the file paths in the reference files. Use an object e.g. {production: 'http://production-asset-host.co'}
      prependHost: null
      # Output filename for a JSON manifest of reference file paths and their digest.
      manifest: ''
      # An array of infixes for alternate versions of files. This is useful when e.g. using retina.js (http://imulus.github.io/retinajs/) (@2x) for high density images.
      infixes: []
      # On slow/async disks, you can get multiple onCompile items during a single build (and thus for a single static asset processing cycle). This defers digestion by a set number of milliseconds, and resets each onCompile invocation.
      delay: 0

Contributing

  1. Add some code
  2. Add some tests
  3. Run npm test
  4. Send a pull request

License

MIT

digest-brunch's People

Contributors

barneyb avatar colinbate avatar john-kurkowski avatar matt-harvey avatar mutewinter avatar razor-x avatar tenorviol avatar tomtomgo avatar

Watchers

 avatar  avatar  avatar

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.