123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- "use strict";
- const { src, dest, watch } = require("gulp");
- const postcss = require("gulp-postcss");
- const browserSync = require("browser-sync").create();
- const sass = require("gulp-sass");
- const babel = require('gulp-babel');
- var sourcemaps = require("gulp-sourcemaps");
- const layout1 = require('layout1')
- const frontMatter = require('./cr-front-matter.js');
- let fileinclude = require('gulp-file-include');
- const htmlbeautify = require('gulp-html-beautify');
- const clearfix = require('postcss-clearfix');
- const color_rgba_fallback = require('postcss-color-rgba-fallback');
- const opacity = require('postcss-opacity');
- const autoprefixer = require('autoprefixer');
- const postcssShort = require('postcss-short');
- const colorFunction = require("postcss-color-function")
- const del = require('del');
- const color = require('colors-cli')
- const path = {
- html: ["src/pages/**/*.html","src/passport/**/*.html"],
- outHtml: "html",
- scss: "src/scss/*.scss",
- css: "assets/css",
- js: "assets/js/*.js"
- };
- function watchScss() {
- const processors = [
- postcssShort,
- clearfix,
- color_rgba_fallback,
- opacity,
- colorFunction,
- autoprefixer
- ];
- return src(path.scss)
- .pipe(sourcemaps.init())
-
- .pipe(sass({ outputStyle: "expanded" }).on("error", sass.logError))
- .pipe(postcss(processors))
- .pipe(sourcemaps.write("./maps"))
- .pipe(dest(path.css))
- .pipe(browserSync.stream());
- }
- function watchHtml() {
- return src(path.html)
- .pipe(frontMatter({
- property: 'fm'
- }))
- .pipe(layout1.ejs('src/layout/layout.ejs'))
- .pipe(fileinclude({
- prefix: '@@',
- basepath: 'src/components/'
- }))
- .pipe(htmlbeautify())
- .pipe(dest(path.outHtml))
- .pipe(browserSync.stream());
- }
- function watchJs() {
- return src(path.js)
-
-
-
-
-
-
- .pipe(browserSync.stream());
- }
- function service() {
- browserSync.init({
- server: "./"
- });
- watch([...path.html,'src/**/*.html','/src/layout/layout.ejs'], watchHtml);
- watch([path.scss,'src/scss/**/*.scss'], watchScss);
- watch(path.js, watchJs);
-
- }
- let log = (str)=>console.log(color.green(str));
- function file_move() {
-
- log('删除原始文件...');
- del('../CZKJ.CMS.Web/wwwroot/assets/**', { force: true });
- log('开始移动文件...');
-
- return src('./assets/**')
- .pipe(dest('../CZKJ.CMS.Web/wwwroot/assets'))
- .on('end', () => {
-
- log('移动完成...');
- })
- }
- exports.service = service;
- exports.move = file_move;
- exports.default = service;
|