
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
gulp-readmin
Advanced tools
Load files from
script
andlink
tags into a stream to do with as you wish
First, install gulp-readmin
as a development dependency:
npm install --save-dev gulp-readmin
Then, add it to your gulpfile.js
:
var readmin = require('gulp-readmin');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
gulp.task('minifyjs', function () {
return gulp.src('templates/layout.html')
.pipe(readmin({type: 'js'))
.pipe(uglify())
.pipe(concat('scripts.min.js'))
.pipe(gulp.dest('build'));
});
Blocks are expressed as:
<!-- build:<pipelineId>(alternate search path) -->
... HTML Markup, list of script / link tags.
<!-- endbuild -->
js
or css
For example:
<!-- build:js -->
<script src="lib/framework.js"></script>
<script src="src/app.js"></script>
<!-- endbuild -->
Type String
Set to js
or css
to filter out the other type. Default is to include both in stream.
Type: String
Default alternate search path for files. Can be overridden by the alternate search path option for a given block.
|
+- gulpfile.js
+- src
| +- templates
| +- layout.php
+- web
| +- index.php
| +- js
| | +- foo.js
| | +- bar.js
| +- css
| | +- normalize.css
| | +- main.css
| +- build
We want to optimize scripts (in the correct order) into scripts.min.js
, and styles into styles.min.css
. layout.php
should contain the following blocks:
<!-- build:css(web) -->
<link rel="stylesheet" href="css/clear.css"/>
<link rel="stylesheet" href="css/main.css"/>
<!-- endbuild -->
<!-- build:js(web) -->
<script src="js/foo.js"></script>
<script src="js/bar.js"></script>
<!-- endbuild -->
We want our files to be generated in the web/build
directory. gulpfile.js
should contain the following tasks:
gulp.task('minifycss', function () {
return gulp.src('src/templates/layout.php')
.pipe(readmin({type:'css'}))
.pipe(minifyCss())
.pipe(concat('styles.min.css'))
.pipe(gulp.dest('web/build'));
});
gulp.task('minifyjs', function () {
return gulp.src('src/templates/layout.php')
.pipe(readmin({type:'js'}))
.pipe(uglify())
.pipe(concat('scripts.min.js'))
.pipe(gulp.dest('web/build'));
});
FAQs
Load files from script and link tags into a stream
We found that gulp-readmin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.