https://github.com/veaba/gulp-replace-srchash
基于gulp 开发html文件路径哈希值
https://github.com/veaba/gulp-replace-srchash
Last synced: about 1 year ago
JSON representation
基于gulp 开发html文件路径哈希值
- Host: GitHub
- URL: https://github.com/veaba/gulp-replace-srchash
- Owner: veaba
- Created: 2017-11-01T15:11:53.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-17T08:47:09.000Z (over 8 years ago)
- Last Synced: 2025-01-30T17:39:45.262Z (over 1 year ago)
- Language: JavaScript
- Size: 200 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gulp-replace-plugins
基于gulp 开发html文件路径哈希值,对于php等模板引擎,非常好用
## usage
① npm install 安装依赖
```npm
npm install
```
② gulp 任务文件
```npm
gulp
```
## style 文件路径必须为
```html
```
如果 为此格式,则会让浏览器无法识别,似乎是gulp 给干掉了:rel="stylesheet
```html
```
## html深度设置
```js
gulp.src(['*.html','./**/*.html','./**/**/*.html','./**/**/**/*.html','./**/**/**/**/*.html'])
```
## 支持自定义目录保留不转换功能
比如保留 plugins 、jquery,不加哈希,以下代码是代码保留plugins不加哈希
```js
//plugins ,由于上一个任务带有问号,此处必带问号
pipe(replace(/(\")*.plugins.*(\")|(\")*.plugins.*.+(\")/g, function (plugins) {
console.info('--------Jquery JS----------')
console.info(plugins)
// return jquery
var data = /(\")*.plugins(\S*)(\?)/g.exec(plugins)
//移除最后一个问号
if (data) {
var str = data[0].replace('?', '')
return str + '"'
}
return plugins
}))
```
## 暂时支持替换在源文件,为此请提前备份项目,防止转换失败
```js
pipe(gulp.dest('./'))
```