gulp4.0.2使用实例(代码片段)

shenzs shenzs     2022-12-08     742

关键词:

gulpfile.js

const gulp = require(‘gulp‘);
const cssnano = require(‘gulp-cssnano‘);
const sass = require(‘gulp-sass‘);
const rename = require(‘gulp-rename‘);
const js = require(‘gulp-uglify‘);
const image_min = require(‘gulp-imagemin‘);
const cache = require(‘gulp-cache‘);
const pipeline = require(‘readable-stream‘).pipeline;
// const bs = require("browser-sync").create();
const connect = require(‘gulp-connect‘);

// gulp.task(‘bs‘, function () 
//     bs.init(
//         ‘server‘:
//             ‘baseDir‘:‘./‘
//         
//     )
// );


gulp.task(‘css‘, function () 
    return pipeline(
        gulp.src(‘./css/*.scss‘),
        sass(),
        gulp.dest(‘./dist/css‘),
        cssnano(),
        rename(‘suffix‘: ‘.min‘),
        gulp.dest(‘./dist/css/‘),
        connect.reload(),
        // bs.stream()
    )


);

gulp .task(‘js‘, function () 
    return pipeline(
        gulp.src(‘./js/*.js‘),
        js(
            ‘toplevel‘:true,
            ‘compress‘:
                ‘drop_console‘:true,
            
        ),
        rename(‘suffix‘: ‘.min‘),
        gulp.dest(‘./dist/js‘),
        connect.reload(),

        // bs.stream()
        )

);
gulp.task(‘html‘, function () 
    return pipeline(
        gulp.src(‘./html/*.html‘),
        gulp.dest(‘./dist/html/‘),
        connect.reload(),
        // bs.stream()
    )
);
gulp.task(‘image‘, function () 
    return pipeline(
        gulp.src(‘./image/*.*‘),
        cache(image_min()),
        gulp.dest("./dist/image/"),
        connect.reload(),
        // bs.stream()

    )
);

gulp.task("watch",function () 
    gulp.watch("css/*.css",gulp.parallel([‘css‘]));
    gulp.watch("html/*.html",gulp.parallel([‘html‘]));
    gulp.watch("image/*.*",gulp.parallel([‘image‘]));
    gulp.watch("js/*.js",gulp.parallel([‘js‘]));
);

gulp.task(‘server‘, function () 
    connect.server(
        root: ‘./‘,
        port: 8888,
        livereload: true
    )
);

gulp.task(‘default‘, gulp.parallel([‘watch‘, ‘server‘]));

package.json


  "name": "zhutou",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": 
    "test": "echo "Error: no test specified" && exit 1"
  ,
  "author": "",
  "license": "ISC",
  "dependencies": 
    "gulp-cli": "^2.3.0"
  ,
  "devDependencies": 
    "browser-sync": "^2.26.10",
    "gulp": "^4.0.2",
    "gulp-cache": "^1.1.3",
    "gulp-connect": "^5.7.0",
    "gulp-cssnano": "^2.1.3",
    "gulp-imagemin": "^7.1.0",
    "gulp-rename": "^2.0.0",
    "gulp-sass": "^4.1.0",
    "gulp-uglify": "^3.0.2",
    "readable-stream": "^3.6.0"
  

 

使用genericservlet实例(代码片段)

使用GenericServlet实例packagecom.kettas.servlet;importjavax.servlet.*;importjava.io.*;publicclassGenDateServletextendsGenericServlet@Overridepublicvoidservice(ServletRequestrequest,ServletResponserespons 查看详情

使用httpservlet简单实例(代码片段)

使用HttpServlet简单实例packagecom.kettas.servlet;importjavax.servlet.*;importjavax.servlet.http.*;importjava.io.*;publicclassLoginServletextendsHttpServlet@Overridepublicvoidservice(HttpServletRequestreque 查看详情

java操作员实例使用(代码片段)

查看详情

multipass中文文档-使用实例命令别名(代码片段)

总目录(待翻译完完善)1.概览2.教程3.使用指引  3.1安装Multipass    3.1.1基于Linux    3.1.2基于macOS    3.1.3基于Windows  3.2管理实例    3.2.1创建实例    3.2.2修改实例    3.2.3使用实例    3.2.4使用实例命令别名... 查看详情

csharp使用工厂模式创建命令实例。(代码片段)

查看详情

请使用makevalid将该实例转换为有效实例(代码片段)

在ArcMap中加载数据(图层)报错:请使用MakeValid将该实例转换为有效实例。请注意,MakeValid可能导致几何图形实例的点轻微移动。报错原因:geometry实例无效执行sql处理图形updatetableNamesetSHAPE=SHAPE.MakeValid()where...参考资料MakeValid(... 查看详情

javagson没有使用实例初始化器!(代码片段)

查看详情

socket使用实例(代码片段)

#socket_server_ssh:服务端importsocket,osserver=socket.socket()server.bind((‘localhost‘,9999))server.listen()whileTrue:conn,addr=server.accept()print("newconn:",addr)whileTrue:data=conn.recv(1024)print("服 查看详情

python脚本使用boto3启动类似于给定实例的实例(代码片段)

查看详情

vue项目axios的使用实例详解(代码片段)

文章目录0、安装1、基本用法2、axios实例2.1、创建axios实例示例代码2.2、axios全局配置示例代码2.3、axios实例配置示例代码2.4、axios请求配置示例代码3、axios请求方法3.1、get请求示例代码3.2、post请求3.3、put和patch请求示例代码3.4、de... 查看详情

使用相同服务的多个实例(代码片段)

我有一个服务,像这样:@Injectable()exportclassEditorService...我有一个组件,像这样:@Component(...template:`<child-component></child-component>`,providers:[EditorService],...)exportclassSomeComponentconstr 查看详情

multipass中文文档-远程使用multipass(代码片段)

总目录(待翻译完完善)1.概览2.教程3.使用指引  3.1安装Multipass    3.1.1基于Linux    3.1.2基于macOS    3.1.3基于Windows  3.2管理实例    3.2.1创建实例    3.2.2修改实例    3.2.3使用实例    3.2.4使用实例命令别名... 查看详情

shawscli:使用标记值描述ec2实例(代码片段)

查看详情

golang使用指针方法接收器作为实例方法(代码片段)

查看详情

使用springcontextholder获取bean实例(代码片段)

1,介绍与使用SpringContextHolder工具类的方法getBean可以获取bean的实例。但是工具类的方法是不是static的,等同于@Autowired注入。解决问题:类中方法是static,方法中使用的对象也必须是static,但正常情况下@Autowired无法注入静态的bea... 查看详情

flex使用实例(代码片段)

flex语法布局,可以参考菜鸟教程。http://www.runoob.com/w3cnote/flex-grammar.html我主要是把flex布局运用到实例中,看看flex布局的效果。1、垂直居中,学习flex布局以后,实现起来很方便;<styletype="text/css">.demodisplay:flex;width:300px;height:... 查看详情

swooletcpudphttp使用实例(代码片段)

阅读目录TCPTCP_SERVER.phpTCP_CUSTOMER.phpUDPUDP_SERVER.phpUDP_CLIENT.phpHTTP指定访问html目录,TCPTCP_SERVER.php<?phpclassTCPprivate$server=null;publicfunction__construct()//创建Server对象,监听12 查看详情

swooletcpudphttp使用实例(代码片段)

阅读目录TCPTCP_SERVER.phpTCP_CUSTOMER.phpUDPUDP_SERVER.phpUDP_CLIENT.phpHTTP指定访问html目录,TCPTCP_SERVER.php<?phpclassTCPprivate$server=null;publicfunction__construct()//创建Server对象,监听12 查看详情