gulp-construct
v0.0.3
Published
concat the css, js and html to construct a html
Downloads
3
Maintainers
Readme
gulp-construct
concat the css, js and html to construct a html
Installation
npm install gulp
npm install gulp-construct
Usage
在根目录创建gulpfile.js,代码如下
var gulp = require('gulp');
var construct = require('gulp-construct');
gulp.task('construct',function() {
gulp.src('src/**/*.html')
.pipe(construct({
includerReg:/<!\-\-include\s+"([^"]+)"\-\->/g,
type: 'html'
}))
.pipe(construct({
includerReg:/<link\s+href\=+"([^"]+)"\s+rel="stylesheet"\/>/g,
type: 'css'
}))
.pipe(construct({
includerReg:/<script\s+src\=+"([^"]+)"><\/script>/g,
type: 'js'
}))
.pipe(gulp.dest('./build'));
});
src/example/index.html, 代码如下
<!--include "./header.html"-->
<link href="src/example/css/index.css" rel="stylesheet"/>
</head>
<body>
<script src="src/example/js/index.js"></script>
<!--include "./footer.html"-->