GithubHelp home page GithubHelp logo

mutewinter / digest-brunch Goto Github PK

View Code? Open in Web Editor NEW
32.0 32.0 11.0 86 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 People

Contributors

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

digest-brunch's Issues

digest for .map files

We would like to use map files also on staging and/or production, tools like sentry can give us more helpful error reports if we attach them. I see that maps have no digests added to the name. Can you give me a hint how I could add the digest to them? I'd try to add this possibility. Thank you.

Digest as Query Parameter

Suggested in #8 by @jsilvestre.

Also as a suggestion (that the rewrite would allow): appending the digest to the file URL, not the file name (to ease versioning). Instead of having:

<script type="text/javascript" src="assets/myscript-2a4z2r.js"></script>

We would have:

<script type="text/javascript" src="assets/myscript.js?2a4z2r"></script>

Paths starting with '/' aren't matched and replaced

DIGEST(stylesheets/app.css) is matched and replaced, but DIGEST(/stylesheets/app.css) is not. An easy work-around is to use /DIGEST(stylesheets/app.css), but it's not very obvious.

I have a feeling it has to do with how the regular expression is escaped (or not), but haven't quite figured it out yet. I'll work on a PR if I have a few minutes.

Relative parent paths result in error

When using DIGEST(../javascript/vendor.js) brunch will fail with fail with

fs.js:524
  return binding.stat(pathModule._makeLong(path));
                 ^
Error: ENOENT, no such file or directory 'javascripts/vendor.js'

Second occurrence of DIGEST on same file is ignored

This:

<img src="DIGEST(/images/fancy.png)" />

Compiles to:

<img src="http://assets.myserver.co/images/fancy-7d2e2b28c6133d.png" />

However, this:

<img src="DIGEST(/images/fancy.png)" />
<img src="DIGEST(/images/fancy.png)" />

Compiles to:

<img src="http://assets.myserver.co/images/fancy-7d2e2b28c6133d.png" />
<img src="DIGEST(/images/fancy.png)" />

Wrong path separator under Windows

Digest paths generated in Windows contain backslash instead of slash for path separator. The code should never ever use the backslash. Slash is also a perfect, valid path folder separator in Windows.

question of .map files

Hi

This is not an issue more a personal question. Sorry for any inconvenience.

How do you make sure eventual .map files are cleaned out and removed from your public dir when building production? Also previous digested files, how do you clean out them? Just remove the whole public dir each time you build with --production?

Thanks

digest-brunch breaks html2js and angular templateCache?

My brunch is setup with html2js concatenating my .tpl.html templates into app.js and it creates an "app" module which injects all the templates into the angular templateCache. Everything works perfect until I install digest-brunch. I'm not trying to point fingers, but I can't quite get to the root of the issue... It seems that somehow digest-brunch is deleting a line where the "app" module was getting created by html2js.

I'm assuming this might either be a bug with fs or something but I'm not entirely sure...

I'm using all the latest versions of brunch and plugins.

Any thoughts?

Not replece DIGEST markers in inner files - recursion

Hi!

For example if i have following files:

  • index.html
    <div class="row line contentspacing center footer" ng-include src="'DIGEST(inner.html)'" ></div >
  • inner.html
    <div class="row line contentspacing center footer" ng-include src="'DIGEST(inner2.html)'" ></div >

DIGEST maker in inner2.html is not replaced

Setting the referenceFiles output path

Hello and thank you for the plugin, that's exactly what we've been looking for for months!

I don't know if it's possible as a Brunch plugin possible but let me ask: I use a .jade file as my main page (served by the server along with some data) and I would like to be able to output it with the digest appended in the folder of my server views rather than in /public/.

I currently do it by post-processing my production build with a Cakefile task so it's not super important if you can't/don't want but that'd be nice!

Cheers,

Prepend environment-specific host to assets' file names

When you deploy assets to different locations depending on the environment it's necessary to be able to prepend the right asset host to the file. For example: in development just use /test.js, in production use http://assetcdn1.com/test.js and in beta use http://assetcdn_beta.com/test.js.

For this to work you need:

  • run digest based on environment instead of production / not-production
  • to be able to specify which host to use in which environment

Why moved to Webpack?

Hi, im new to brunch js and don't know any future pitfalls with it, can you explain why you switched to webpack, so i could decide to continue with brunch on my new project!

Add option to strip DIGEST directive in development/watch

Apologies in advance if this is already possible, but I couldn't figure out how to do it.

We're using digest-brunch to version our app's javascript and css in our main index.html. However we use the same index file in both development/watch and for production builds. When running in production everything works great. In development (and brunch watch) we don't want to perform the digest, so it'd be ideal to have the DIGEST directive stripped from the asset path.

Our index file is actually a handlebars template compiling in express so I'm able to work around the issue with a switch and only use the DIGEST version of the files when in production. Eg:

{{#if production}}
  <script src="DIGEST(/javascripts/vendor.js)"></script>
  <script src="DIGEST(/javascripts/app.js)"></script>
{{else}}
  <script src="/javascripts/vendor.js"></script>
  <script src="/javascripts/app.js"></script>
{{/if}}

We'd like to also have the digest versioning goodness for our individual image/font assets that we reference in our css. But the logic gate for environment won't work in those files so I'd really like to find a way to just un-digest in development. For example:

background: url('DIGEST(/images/background-image.png)') no-repeat left top;

In development translates to:

background: url('/images/background-image.png') no-repeat left top;

If this isn't already possible and there's interest I'd be willing to try and code up a solution and submit a PR.

Thanks in advance.

No file with digest created for alternate version of file

In my case, I use retina.js to get @2x version of images. The normal image gets a digest, but since the @2x version isn't referenced anywhere in the source, there is no digest file created for the alternate.

We could create a list of infixes, like infixes: ['@2x'], and scan for every file that gets a digest if there is an alternate version with the infix. A problem is that the alternate file will have to get the same digest as the original file, at least in this use case. This can be done, but does feel a little counter-intuitive as to what the digest actually means. That last problem would however be canceled out (I think) by #14.

Any ideas/comments?

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.