3 Star 1 Fork 0

蓝飞 / gulp-file-assets

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

gulp-file-assets

Build Status Coverage Status Version License Dependencies DevDependencies

A gulp plugin to extract file assets.

Attention: Version 2.0.0+ is not compatible with 1.0.0+.

Usage

First, install gulp-file-assets as a development dependency:

npm install --save-dev gulp-file-assets

Then, add it to your gulpfile.js:

var gulp = require('gulp');
var fileAssets = require('gulp-file-assets');

gulp.task('default', function(){
	return gulp
		.src('index.html')
		.pipe(fileAssets())
		.pipe(gulp.dest('dist'));
});

Notice: If your source files are in a folder, please set the base option of gulp.src(options) to a right path.

Example

index.html

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>gulp-file-assets</title>
	<link rel="stylesheet" href="css/style.css">
</head>
<body>
	<a href="sample.html">Link</a>
</body>
</html>

style.css

#logo {
	background: url(../img/logo.png);
}

gulpfile.js

var gulp = require('gulp');
var fileAssets = require('gulp-file-assets');

gulp.task('default', function() {
	return gulp
		.src('index.html')
		.pipe(fileAssets({
			excludes: ['html']
		}))
		.pipe(gulp.dest('dist'));
});
// => ['dist/index.html', 'dist/css/style.css', 'dist/img/logo.png']

API

fileAssets(options)

options

Type: Object

options.exts

File extensions to be extracted.

Type: Array

Default:

[
	'js', 'css', 'html', 'tpl',
	'jpg', 'jpeg', 'png', 'gif', 'svg', 'webp',
	'ttf', 'eot', 'otf', 'woff'
]
options.excludes

File extensions to be excluded.

Type: Array

Default: []

options.includeSrc

Whether to put the source files to the pipeline.

Type: Boolean

Default: true

options.depth

The depth of files to extract.

Type: Number

Default: null

options.ignores

A file path/RegExp list to be ignored.

Type: Array

Default: []

The MIT License (MIT) Copyright (c) 2015 Lanfei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个提取文件引用资源的 gulp 插件。 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
NodeJS
1
https://gitee.com/lanfei/gulp-file-assets.git
git@gitee.com:lanfei/gulp-file-assets.git
lanfei
gulp-file-assets
gulp-file-assets
master

搜索帮助