mutewinter / digest-brunch Goto Github PK
View Code? Open in Web Editor NEWUnsupported: A Brunch plugin that appends a unique SHA digest to asset filenames.
Home Page: https://www.npmjs.org/package/digest-brunch
License: MIT License
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
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!
Digest-brunch crashes if a file is referenced in a DIGEST
tag does not exist. Instead, it should print warning and continue processing.
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?
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:
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'
Hi!
For example if i have following files:
DIGEST maker in inner2.html is not replaced
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?
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.
Travis is reporting success because the test command reports success. But there are 26 failing tests. https://travis-ci.org/mutewinter/digest-brunch
will you update the project soon? because we love it! thank you for your work!
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.
Renaming and replacing occurrences of DIGEST
ad-hoc was a bad approach. Instead, we should generate a manifest file a la Rails and then do the rename / replacements based on its contents. We could optionally leave the manifest file around as an artifact that allows
Examples in the wild:
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.
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)" />
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
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,
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.
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>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.