# gulp-add-query-fragment **Repository Path**: rioli/gulp-add-query-fragment ## Basic Information - **Project Name**: gulp-add-query-fragment - **Description**: Add the query parameter and the fragment anchor to the specified element link - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-10-31 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # gulp-add-query-fragment Add the query parameter and the fragment anchor to the specified element link First you should intall `gulp-add-query-fragment` by npm, open your terminal and input the bash ``` npm install gulp-add-query-fragment ``` Use examples: ``` const gulp = require('gulp') const addQueryFragment = require('gulp-add-query-fragment') gulp.task('addQueryFragment', function () { //Select the file or directory you want to operate gulp.src(['./index.html']) .pipe(addQueryFragment([ { //css selector selector: 'link,a,script,img,iframe', //Add the query parameter to the href or src address of the element selected by the css selector //such as './library/bootstrap/bootstrap.min.js' will be modified to //'./library/bootstrap/bootstrap.min.js?t=20170809&lang=chinese' query: { t: 20170809,lang: 'chinese' }, //Link anchor,such as:‘https://www.example.com/index.html’,will be modified to // ‘https://www.example.com/index.html#left’ fragment: 'left' }, { selector: 'script#index', query: { t: 'kk', lang: 'en' }, fragment: 'center', // Whether to overwrite the previous query parameters overwrite: true } ])) .pipe(gulp.dest('./dist')) }) ``` open your terminal and input the bash,you will see the effect ``` gulp addQueryFragment ```