Gathering detailed insights and metrics for gulp-usemin
Gathering detailed insights and metrics for gulp-usemin
Gathering detailed insights and metrics for gulp-usemin
Gathering detailed insights and metrics for gulp-usemin
gulp-jade-usemin
Gulp plugin for running usemin on Jade files
gulp-usemin-extend
Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views).
gulp-usemin2
Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views). Based off of gulp-usemin by Zont.
gulp-usemin-reloaded
A better usemin.
npm install gulp-usemin
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (92.69%)
HTML (6.79%)
CSS (0.52%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
336 Stars
200 Commits
91 Forks
6 Watchers
2 Branches
34 Contributors
Updated on Apr 19, 2025
Latest Version
0.3.30
Package Id
gulp-usemin@0.3.30
Size
12.89 kB
NPM Version
6.10.2
Node Version
12.6.0
Published on
Aug 07, 2019
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Deprecated. Please use Browserify or Webpack
Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views).
This task is designed for gulp >= 3 and node >= 4.0.
Attention: v0.3.0 options is not compatible with v0.2.0.
First, install gulp-usemin
as a development dependency:
1npm install --save-dev gulp-usemin
Then, add it to your gulpfile.js
:
1var usemin = require('gulp-usemin'); 2var uglify = require('gulp-uglify'); 3var htmlmin = require('gulp-htmlmin'); 4var cleanCss = require('gulp-clean-css'); 5var rev = require('gulp-rev'); 6 7 8gulp.task('usemin', function() { 9 return gulp.src('./*.html') 10 .pipe(usemin({ 11 css: [ rev() ], 12 html: [ htmlmin({ collapseWhitespace: true }) ], 13 js: [ uglify(), rev() ], 14 inlinejs: [ uglify() ], 15 inlinecss: [ cleanCss(), 'concat' ] 16 })) 17 .pipe(gulp.dest('build/')); 18});
If you need to call the same pipeline twice, you need to define each task as a function that returns the stream object that should be used.
1gulp.task('usemin', function() { 2 return gulp.src('./*.html') 3 .pipe(usemin({ 4 css: [ rev ], 5 html: [ function () {return htmlmin({ collapseWhitespace: true });} ], 6 js: [ uglify, rev ], 7 inlinejs: [ uglify ], 8 inlinecss: [ cleanCss, 'concat' ] 9 })) 10 .pipe(gulp.dest('build/')); 11});
Blocks are expressed as:
1<!-- build:<pipelineId>(alternate search path) <path> --> 2... HTML Markup, list of script / link tags. 3<!-- endbuild -->
An example of this in completed form can be seen below:
1<!-- build:css style.css --> 2<link rel="stylesheet" href="css/clear.css"/> 3<link rel="stylesheet" href="css/main.css"/> 4<!-- endbuild --> 5 6<!-- build:htmlimport components-packed.html --> 7<link rel="import" href="components-a.html"> 8<link rel="import" href="components-b.html"> 9<!-- endbuild --> 10 11<!-- build:js js/lib.js --> 12<script src="../lib/angular-min.js"></script> 13<script src="../lib/angular-animate-min.js"></script> 14<!-- endbuild --> 15 16<!-- build:js1 js/app.js --> 17<script src="js/app.js"></script> 18<script src="js/controllers/thing-controller.js"></script> 19<script src="js/models/thing-model.js"></script> 20<script src="js/views/thing-view.js"></script> 21<!-- endbuild --> 22 23<!-- build:remove --> 24<script src="js/localhostDependencies.js"></script> 25<!-- endbuild --> 26 27<!-- build:inlinejs --> 28<script src="../lib/angular-min.js"></script> 29<script src="../lib/angular-animate-min.js"></script> 30<!-- endbuild --> 31 32<!-- build:inlinecss --> 33<link rel="stylesheet" href="css/clear.css"/> 34<link rel="stylesheet" href="css/main.css"/> 35<!-- endbuild -->
Type: String
Alternate root path for assets. New concated js and css files will be written to the path specified in the build block, relative to this path. Currently asset files are also returned in the stream.
Type: String
Default alternate search path for files. Can be overridden by the alternate search path option for a given block.
Type: Array
If exist used for modify files. If does not contain string 'concat', then it added as first member of pipeline
Type: String
Relative location to html file for new concatenated js and css.
Type: Boolean
Keep HTML comment when processing
Type: Object
Attach HTML attributes to the output js file. For Example :
1gulp.task('usemin', function() { 2 return gulp.src('./index.html') 3 .pipe(usemin({ 4 html: [], 5 jsAttributes : { 6 async : true, 7 lorem : 'ipsum', 8 seq : [1, 2, 1] 9 }, 10 js: [ ], 11 js1:[ ], 12 js2:[ ] 13 })) 14 .pipe(gulp.dest('./')); 15});
Will give you :
1<script src="./lib.js" async lorem="ipsum" seq="1"></script> 2<script src="./app.js" async lorem="ipsum" seq="2"></script> 3<script src="./extra.js" async lorem="ipsum" seq="1"></script>
As your built script tag.
Type: Boolean
Allows missing resources to be skipped, instead of throwing an error.
|
+- app
| +- index.html
| +- assets
| +- js
| +- foo.js
| +- bar.js
| +- css
| +- clear.css
| +- main.css
+- dist
We want to optimize foo.js
and bar.js
into optimized.js
, referenced using relative path. index.html
should contain the following block:
<!-- build:css style.css -->
<link rel="stylesheet" href="css/clear.css"/>
<link rel="stylesheet" href="css/main.css"/>
<!-- endbuild -->
<!-- build:js js/optimized.js -->
<script src="assets/js/foo.js"></script>
<script src="assets/js/bar.js"></script>
<!-- endbuild -->
We want our files to be generated in the dist
directory. gulpfile.js
should contain the following block:
1gulp.task('usemin', function () { 2 return gulp.src('./app/index.html') 3 .pipe(usemin({ 4 js: [uglify()] 5 // in this case css will be only concatenated (like css: ['concat']). 6 })) 7 .pipe(gulp.dest('dist/')); 8});
This will generate the following output:
|
+- app
| +- index.html
| +- assets
| +- js
| +- foo.js
| +- bar.js
+- dist
| +- index.html
| +- js
| +- optimized.js
| +- style.css
index.html
output:
<link rel="stylesheet" href="style.css"/>
<script src="js/optimized.js"></script>
#####0.3.30
#####0.3.29
#####0.3.28
#####0.3.27
#####0.3.26
#####0.3.24
#####0.3.23
#####0.3.22
#####0.3.21
#####0.3.20
#####0.3.18
#####0.3.17
#####0.3.16
#####0.3.15
#####0.3.14
#####0.3.13
#####0.3.12
#####0.3.11
#####0.3.10
#####0.3.9
#####0.3.8
#####0.3.7
#####0.3.6
#####0.3.5
#####0.3.4
#####0.3.3
#####0.3.2
#####0.3.1
#####0.3.0
#####0.2.3
#####0.2.2
#####0.2.1
#####0.2.0
#####0.1.4
#####0.1.3
#####0.1.1
#####0.1.0
#####0.0.2
#####0.0.1
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 9/20 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More