|
|
|
@ -4,14 +4,19 @@ var connect = require("gulp-connect");
|
|
|
|
|
var minifyHtml = require("gulp-minify-html"); //压缩html
|
|
|
|
|
|
|
|
|
|
var rename = require("gulp-rename"); //重命名
|
|
|
|
|
var scssToCss = require("gulp-sass")(require('sass')); //scss to css
|
|
|
|
|
var minifyCss = require("gulp-minify-css"); //压缩CSS
|
|
|
|
|
var autoprefixer = require("gulp-autoprefixer");
|
|
|
|
|
var scssToCss = require("gulp-sass")(require('sass')); //scss to css
|
|
|
|
|
|
|
|
|
|
var clean = require("gulp-clean");
|
|
|
|
|
|
|
|
|
|
var fileinclude = require("gulp-file-include");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var babel = require('gulp-babel');
|
|
|
|
|
var webpack = require('webpack-stream');
|
|
|
|
|
var sourceMap = require('gulp-sourcemaps');
|
|
|
|
|
var webpackConfig = require ("./webpack/webpack.config.js");
|
|
|
|
|
// 创建
|
|
|
|
|
gulp.task("connect", function () {
|
|
|
|
|
connect.server({
|
|
|
|
@ -37,11 +42,10 @@ gulp.task("html", function () {
|
|
|
|
|
return gulp
|
|
|
|
|
.src("src/*.html")
|
|
|
|
|
.pipe(fileinclude()) //替换头部底部
|
|
|
|
|
.pipe(minifyHtml()) //执行压缩
|
|
|
|
|
.pipe(minifyHtml({quotes:true})) //执行压缩
|
|
|
|
|
.pipe(gulp.dest("dist"))
|
|
|
|
|
.pipe(connect.reload());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task("scss", function () {
|
|
|
|
|
return gulp
|
|
|
|
|
.src("src/static/scss/*.scss")
|
|
|
|
@ -65,18 +69,41 @@ gulp.task("clean", function () {
|
|
|
|
|
|
|
|
|
|
gulp.task("watchs", function () {
|
|
|
|
|
gulp.watch("src/*.html", gulp.series("html"));
|
|
|
|
|
gulp.watch("src/tpl/*.html", gulp.series("html"));
|
|
|
|
|
gulp.watch("src/static/scss/*.scss", gulp.series(
|
|
|
|
|
"scss",
|
|
|
|
|
gulp.parallel("css")
|
|
|
|
|
));
|
|
|
|
|
gulp.watch("src/static/js/*.js", gulp.series("script"));
|
|
|
|
|
gulp.watch("gulpfile.js", gulp.series("default"));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('script', () => {
|
|
|
|
|
return gulp.src('src/static/js/*.js')
|
|
|
|
|
.pipe( sourceMap.init() )
|
|
|
|
|
.pipe(babel({
|
|
|
|
|
presets: ['@babel/preset-env']
|
|
|
|
|
}))
|
|
|
|
|
.pipe(webpack(webpackConfig))
|
|
|
|
|
.pipe(sourceMap.write())
|
|
|
|
|
.pipe(gulp.dest('dist/static/js/'))
|
|
|
|
|
.pipe(connect.reload()); //更新;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task("lib", function () {
|
|
|
|
|
return gulp
|
|
|
|
|
.src("src/static/lib/*.js")
|
|
|
|
|
.pipe(gulp.dest("dist/static/lib/"))
|
|
|
|
|
.pipe(connect.reload()); //更新;
|
|
|
|
|
});
|
|
|
|
|
gulp.task(
|
|
|
|
|
"default",
|
|
|
|
|
gulp.series(
|
|
|
|
|
"clean",
|
|
|
|
|
"scss",
|
|
|
|
|
gulp.parallel("html", "css"),
|
|
|
|
|
gulp.parallel("html","lib","script", "css"),
|
|
|
|
|
gulp.parallel("connect", "watchs")
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
@ -85,6 +112,7 @@ gulp.task(
|
|
|
|
|
"build",
|
|
|
|
|
gulp.series(
|
|
|
|
|
"clean",
|
|
|
|
|
gulp.parallel("html", "css")
|
|
|
|
|
"scss",
|
|
|
|
|
gulp.parallel("html","lib","script", "css")
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|