1.7.2 • Published 7 years ago

gulp-mm v1.7.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

##wechat web rebuild team dev tool

###about us http://mmrb.github.io

###installation

npm install -g gulp
npm install --save-dev gulp gulp-mm

###usage

create gulpfile.js

var gulp = require('gulp');
var mm = require('gulp-mm');

gulp.task('build', function(){
    mm.watch('./src/**/*.less')
      .pipe(mm.less())
      .pipe(mm.sprite())
      .pipe(gulp.dest('./preview'))
      .pipe(mm.uglify())
      .pipe(gulp.dest('./dist'));
      
    mm.watch('./src/**/*.html')
      .pipe(mm.inline())
      .pipe(mm.optimization())
      .pipe(gulp.dest('./preview'))
      .pipe(mm.resolve())
      .pipe('./dist');
});

gulp.task('server', function(){
    mm.server.start({root: __dirname + '/preview'});
});

gulp.task('default', ['build', 'server']);

###api

server

express + socket.io(for live reload)

mm.server.start({root: __dirname + '/preview'});

// when file change
mm.server.emit('change');

inline

you can import other file in your html, or javascript file with inline plugin, for example:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>sprite</title>
    <!-- output: <style>content of style.less(after compile to css) </style> -->
    <link rel="stylesheet" href="./style.less?__inline"/>
</head>
<body>
    <!-- output: <img src="base64 of hello.png" -->
    <img src="hello.png?__inline"/>

    <!-- output: content of fragment -->
    <link rel="import" href="./fragment.html?__inline"/>
</body>
</html>
// it will be replaced with content of zepto.js here
__inline("../lib/zepto.js");

$(function(){
    console.log('hello world!');
});
.icon_new{
    display: inline-block;
    width: 16px;
    height: 16px;
    /* background's image will be replaced with icon's base64 format*/
    background: url("../images/icon/new.png?__inline");
}

sprite

the icon images will be concat to one image, which is named as current css file plus '_z.png', for example: icon_z.png.

/* icon.css */

.icon_new{
    display: inline-block;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    /* here will be replace sprite image path, and auto set the background-position */
    background: url("../images/icon/new.png?__sprite");
}

.icon_add{
    display: inline-block;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    background: url("../images/icon/add.png?__sprite");
}

.icon_search{
    display: inline-block;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    /* here will be replace @2x sprite image path, and auto set the background-position and background-size*/
    /* for ratina */
    background: url("../images/icon/add@2x.png?__sprite");
}
1.7.2

7 years ago

1.7.0

8 years ago

1.6.7

9 years ago

1.6.6

9 years ago

1.6.5

9 years ago

1.6.4

9 years ago

1.6.3

9 years ago

1.6.2

9 years ago

1.6.1

9 years ago

1.6.0

9 years ago

1.5.8

9 years ago

1.5.6

9 years ago

1.5.4

9 years ago

1.5.3

9 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.7

9 years ago

1.4.6

9 years ago

1.4.5

9 years ago

1.4.4

9 years ago

1.4.3

9 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.7

9 years ago

1.3.6

9 years ago

1.3.5

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.35

9 years ago

0.0.34

9 years ago

0.0.33

9 years ago

0.0.32

9 years ago

0.0.31

9 years ago

0.0.30

9 years ago

0.0.29

9 years ago

0.0.28

9 years ago

0.0.27

9 years ago

0.0.26

9 years ago

0.0.25

9 years ago

0.0.24

9 years ago

0.0.23

9 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.20

9 years ago

0.0.19

9 years ago

0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago