1 Star 0 Fork 0

tianyulin/choco89555-m-website

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gulpfile-prod.js 3.01 KB
一键复制 编辑 原始数据 按行查看 历史
choco895 提交于 2019-09-23 20:21 . 拉勾网M站路由功能实现
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);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/choco89555/choco89555-m-website.git
git@gitee.com:choco89555/choco89555-m-website.git
choco89555
choco89555-m-website
choco89555-m-website
田玉林

搜索帮助