代码拉取完成,页面将自动刷新
const {
src,
dest,
series,
parallel
} = require("gulp");
const concat = require("gulp-concat");
const sass = require("gulp-sass");
const webpack = require("webpack-stream");
const rev = require("gulp-rev");
const del = require("del");
const revCollector = require("gulp-rev-collector");
function compileHTML() {
return src("src/views/**/*.html")
.pipe(dest("dist/views/"));
}
function compileIndexCSS() {
return src(["src/styles/index/*.scss", "src/styles/reset.scss"])
.pipe(sass().on('error', sass.logError))
.pipe(concat("index.min.css"))
.pipe(rev())
.pipe(dest("dist/styles/"))
.pipe(rev.manifest("css-manifest.json"))
.pipe(dest("./rev/"));
}
function compileDetailCSS() {
return src(["src/styles/detail/*.scss", "src/styles/reset.scss"])
.pipe(sass().on('error', sass.logError))
.pipe(concat("detail.min.css"))
.pipe(rev())
.pipe(dest("dist/styles/"))
.pipe(rev.manifest("css-manifest.json"))
.pipe(dest("./rev/"));
}
function compileJS() {
return webpack({
mode: "development",
// entry: "./src/scripts/app.js",
entry: {
"app": "./src/scripts/app.js",
"detail": "./src/scripts/detail.js"
},
devtool: "source-map",
output: {
filename: "[name].min.js",
},
module: {
rules: [{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-runtime']
}
}
},
{
test: /\.html$/,
loader: "string-loader"
}
]
}
})
.pipe(rev())
.pipe(dest("dist/scripts/"))
.pipe(rev.manifest("js-manifest.json"))
.pipe(dest("./rev/"));
}
function copyStatic() {
return src("src/static/**/*.*")
.pipe(dest("dist/static/"));
}
function revCollect() {
return src(['rev/**/*.json', './dist/**/*.html'])
.pipe(revCollector({
replaceReved: true,
dirReplacements: {
'./styles/': './styles/',
'./scripts/': './scripts/',
// 'cdn/': function (manifest_value) {
// return '//cdn' + (Math.floor(Math.random() * 9) + 1) + '.' + 'exsample.dot' + '/img/' + manifest_value;
// }
}
}))
.pipe(dest('./dist/'));
}
function clean(path) {
return function () {
return del(path);
}
}
exports.default = series(clean("./dist"), parallel(compileHTML, compileIndexCSS, compileDetailCSS, compileJS, copyStatic),revCollect);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。