8000 GitHub - wntd/gulp-merge-link: gulp plug-in. Merge <link> or <script> on html.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gulp plug-in. Merge <link> or <script> on html.

License

Notifications You must be signed in to change notification settings

wntd/gulp-merge-link

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-merge-link

Merge <link> or <script> on html. This is necessary work with gulp-concat

Install

npm install gulp-replace

Normal Usage

var merge=require('gulp-merge-link');

gulp.task('merge', function () {
    gulp.src('./html/index.html')
        .pipe(merge({
            'base.css':['header.css','footer.css','./lib/common.css'],
            'base.js':['lib/jquery.js','header.js']
        }))
        .pipe(gulp.dest('dist/html/'));
});

GLOB Usage

var merge=require('gulp-merge-link');

gulp.task('merge', function () {
    gulp.src('html/*.html')
        .pipe(merge({
            'base.css':['header.css','footer.css','./lib/*.css'],
            'base.js':['lib/*.js','header.js']
        }))
        .pipe(gulp.dest('dist/html/'));
});

Print Info Usage

var merge = require('gulp-merge-link');

gulp.task('merge', function () {
    gulp.src('html/*.html')
        .pipe(merge({
                'base.css': ['header.css', 'footer.css', './lib/*.css'],
                'base.js': ['lib/*.js',<
808A
/span> 'header.js']
            }, {debug: true}
        ))
        .pipe(gulp.dest('dist/html/'));
});
});

API

merge(options,config)

options

Type:{Array}

key/value Map.

key:{String} The new Url of some file concated.

value: {Array} Urls will be replaced.

config

Type:{Object}

Default:{debug:false}

Print some information about script or link replaced.

Example

Before:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="footer.css"/>
    <link href="header.css"/>
    <link rel="stylesheet" href="./lib/ini.css" />
</head>
<body>
<script src="./lib/jquery.js"></script>
<script type="text/javascript" src="header.js"></script>
<script src="footer.js"></script>
</body>
</html>

After require('gulp-merge-link')(options)

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="base.css"/>


</head>
<body>
<script type="text/javascript" src="base.js"></script>

<script src="footer.js"></script>
</body>
</html>

About

gulp plug-in. Merge <link> or <script> on html.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0