gulp-rev | Static asset revisioning by appending content hash | Build Tool library
kandi X-RAY | gulp-rev Summary
kandi X-RAY | gulp-rev Summary
Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gulp-rev
gulp-rev Key Features
gulp-rev Examples and Code Snippets
Community Discussions
Trending Discussions on gulp-rev
QUESTION
I have gulp file that is having issues with latest update to gulp 4 I am getting assertion errors (AssertionError [ERR_ASSERTION]: Task function must be specified) and it seems (from googling) to have to do with how tasks are defined, but not sure if this is the case here and what needs to change. Node: node -v v14.16.0
CLI version: 2.3.0 Local version: 4.0.2
NPM: 6.14.11 Here is the code
...ANSWER
Answered 2021-Jun-11 at 04:09So there are a few things wrong with your code.
gulp.task('styles', ['wiredep'], function() {
for example should be
gulp.task('styles', gulp.series('wiredep', function() {
etc.
gulp.task
only takes three arguments. You may have more places in your code like this.
gulp.watch([path.source + 'styles/**/*'], ['styles']);
might actually be fine but lets be careful and make it a little more future-proof:
gulp.watch([path.source + 'styles/**/*'], gulp.series('styles'));
Etc. change all of these in your watch
task.
With gulp.series
and gulp.parallel
you no longer need something like runSequence
. So replace
QUESTION
I understand why we need to make the names of CSS, JavaScript and media files like images unique when building the project for production. I don't understand why the using of MD5 for this effect reaching is so popular, for example:
To generate the filename like main.7e2c49a622975ebd9b7e.js
, we need to read the file and create the MD5 has of the content. Seems like it will take a lot of time, especially in HD images and videos case.
There are some other alternatives how to generate the unique file name:
- Using the UNIX timestamp
- Using the
Math.random()
Just two instances, but I don't see the reason to explore more.
...ANSWER
Answered 2021-Jan-24 at 02:56A primary reason is that if the files contents don't change, the hash won't change. And if the hash doesn't change that means your users' browsers won't have to download the files after your next deployment (as the browser has cached the file from a previous pageload).
If you used timestamp, every filename would change for every deployment, resulting in your users' browsers having to redownload every file in your project...even files whose content did not change. This can have a hugely negative performance hit if you are deploying code frequently.
QUESTION
Iam using gulp CLI version: 2.2.1 Local version: 4.0.2 The node version is 12.16.3 MY code of gulpfile.js is
...ANSWER
Answered 2020-Jun-03 at 21:28Replace these two tasks:
QUESTION
Below is my gulpfile. I am trying to generate minified css from scss and then rename it using gulp-rev. Running gulp clean:assets then gulp scss then gulp css works perfectly. But running gulp build does not do the task. The minified css gets stored in ./assets/css but the renamed css is not getting stored in ./public/assets
...ANSWER
Answered 2020-May-09 at 13:44gulp.task('scss', ()=> {
return new Promise((resolve, reject) => {
return gulp.src('./assets/scss/**/*.scss')
.pipe(sass())
.pipe(cssnano())
.pipe(gulp.dest('./assets/css'))
.on('end', resolve)
.on('error', reject);
});
});
QUESTION
I'm currently running into trouble when releasing new versions of my SPA since the html templates are being cached by the browser.
My SPA uses Angular 1.5, ocLazyload and ui-router. I have configured gulp tasks to use cache-busting technique (with gulp-rev), and it is working pretty well, at least with the script and css files. However, when we have changes on html files the browser keeps loading the old version. Sometimes even refreshing the page with Ctrl+F5 doesn't solve the problem and it keeps showing the old version of html.
In addition, configuring the browser to not make cache of html files isn't desirable (specially for mobile), since html changes may occur not very often.
Is there any good solution that address this problem for fetching html files only when there is new versions of it?
Thanks in advance!
...ANSWER
Answered 2017-Mar-15 at 18:09As you are using gulp, you could make use of gulp-angular-templateCache
, which is a gulp plugin to collect all your html files, concatenate them into a single javascript file and add them to AngularJS' $templateCache
based on the file path.
QUESTION
I am using es6 syntax in my angular JS project but it throws error when run gulp build
, search over github and So but some saying this is error due to gulp uglify while some say this is babel issue and other say ng-annonate issue.
ubuntu 14.04
node -v : 8.4.0
npm -v : 5.3.0
babel --version : 6.26.0 (babel-core 6.26.0)
package.json
...ANSWER
Answered 2017-Sep-06 at 09:50It could simply be because your app needs a lot of memory to be built; node.js has a hard 1.4Gb limit for memory allocations. See this question on how to increase this limit. Let us know if this helps!
QUESTION
I am using Gulp v.4 from npm with gulp-rev and gulp-rev-rewrite mods for prevent Cash Busting CSS and JS. But even if I already read lots of guides and notes, it still not work as it should. Actually gulp-rev mod working well, but when I want rewrite links inside html (for mine example latte file), it not rewrite that names.
...ANSWER
Answered 2019-Jun-10 at 10:11By default, gulp-rev-rewrite
only replaces filename occurrences in js, css, html and handlebars files. You can use the replaceInExtensions
to override that default. In this case:
QUESTION
Context: I have a production application (here if you want to look) that is currently using static asset revisioning using the gulp-rev-all
package which is like gulp-rev
except that it also handles dependencies when generating content hashes. It generates a new set of files that have static names (eg goals.js
becomes goals.6a5aa614.js
) and that reference each other using those static names. Then I serve those files up with the Fastly CDN on production, so my NodeJS server isn't being actively used for static assets. This has been working great.
Now I'm in the process of making the site work offline with service-workers. Since I'd done a lot of work on the syncing logic last year, the dynamic part of the site has been pretty easy to overhaul. But I'm a bit at a loss for what to do with my static assets.
I figured I'd use workbox, and that seems to work okay. But the workbox precache
uses queries for busting the cache rather than changing filenames, and it seems dumb to do both. But if I stop using the versioned names, then how do I bust the cache on browsers that don't support service worker?
(I have another related question, which is does it make sense to keep using Fastly given that Fastly's responses will be opaque to the SW and therefore not necessarily a good option for precaching? Although without Fastly the app would become a lot slower for anyone who isn't using service workers, which sounds antithetical to the PWA approach. Should I add an nginx cache or something? (I have little idea what this is but I've heard it mentioned a few times))
It seems to me like there's got to be an elegant solution for this, but my understanding of gulp
is sufficiently limited that it's hard for me to know what is possible, and my understanding of ServiceWorkers & caching is sufficiently limited that it's hard for me to know exactly what I want.
I'm therefore having trouble getting any traction on this question:
How can I adapt my gulp static asset revisioning to work with ServiceWorkers?
One thing that would be helpful is just a link to examples of how other production applications handle this.
...ANSWER
Answered 2019-Jan-07 at 07:42Service worker works best on top of good regular caching strategy. You should continue to revision your static file names then cache them in the service worker. Avoid libraries that alter the URL via a query string, you don't need that feature as you're already revisioning the URL.
If your assets are served from another origin (I guess this is what you mean when you're talking about Fastly), then allow them to be requested via CORS (via Access-Control-Allow-Origin: *
), that means they won't be opaque.
QUESTION
I have a project using Angular.js for which I created some gulp tasks a long while ago. I recently got a new computer and tried to run it but it silently failed (no errors in the log) on my browserify task.
...ANSWER
Answered 2018-Nov-30 at 14:52I restructured the browserify-task and removed the rename, since the filename parameter in the vinyl-source-stream was already doing the renaming, I didn't really need it:
QUESTION
After installing npm to the blur-admin template https://github.com/akveo/blur-admin
I had a number of issues which I fixed by using the run recomendations in the npm audit dialog. However I cant fix one even after running
...ANSWER
Answered 2018-Nov-21 at 22:29This usually means that one of the other project dependencies in your project.json
has a dependency of lodash and they have not patched their pacakge.json
.
The error states which one it is: "browser-sync-spa" and the path to it:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gulp-rev
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page