https://github.com/brainpoint/gulp-copy-content
copy file content to html
https://github.com/brainpoint/gulp-copy-content
Last synced: 5 months ago
JSON representation
copy file content to html
- Host: GitHub
- URL: https://github.com/brainpoint/gulp-copy-content
- Owner: brainpoint
- Created: 2017-11-13T15:15:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-13T15:18:21.000Z (over 8 years ago)
- Last Synced: 2025-01-30T07:38:09.817Z (over 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Installation
```bash
npm install gulp --save-dev
npm install gulp-copy-content --save-dev
```
## Usage
文件目录结构如下:
```
├── gulpfile.js # gulpfile文件
├── src/ # 源文件目录
└── index.html # index.html
└── template/ # 模板目录
└── header.html # 模板文件
└── dist/ # 编译目录
```
html文件,代码如下
```html
```
在根目录创建gulpfile.js,代码如下
```js
var gulp = require('gulp');
var precompile = require('gulp-copy-content');
gulp.task('copy', function(){
return gulp.src('src/*.html')
.pipe(precompile({
reg: //g, // 匹配的文件正则.
baseSrc: "", // 设置根目录之后不需要编写完整的路径.
}))
.pipe(gulp.dest('dist/'))
});
```
执行
```bash
gulp copy
```
task结束后会将制定的文件内容复制到注释的位置.