assets plugin for gulp
First, install gulp-assets
as a development dependency:
npm install --save-dev gulp-assets
Then, add it to your gulpfile.js
:
var assets = require("gulp-assets");
gulp.src("./src/*.html")
.pipe(assets({
js: true,
css: false
}))
.pipe(gulp.dest("./dist"));
Type: either a boolean
or a string
Default: true
Whether you wish to get javascript files. If a string is used, only the javascript files between the appropriate comment tags will be used.
Example:
<!-- build:myJsTag -->
<script src="js/foo.js"></script>
<!-- endbuild -->
assets({
js: 'myJsTag',
css: false
})
You will only get js/foo.js
in your build stream
Type: either a boolean
or a string
Default: false
Whether you wish to get css files. If a string is used, only the css files between the appropriate comment tags will be used.
Example:
<!-- build:myCssTag -->
<link rel="stylesheet" href="css/foo.css"/>
<!-- endbuild -->
assets({
js: false
css: 'myCssTag',
})
Type: string
Default: undefined
If set, will be used as a base when building the files' paths.
assets.js(<optional tagname>); // Only js files (between comment tags if tagname is set)
assets.css(<optional tagname>); // Only css files (between comment tags if tagname is set)
- @kjbekkelund
- @Zweer
- @shinnn