3.0.2 • Published 4 years ago

slue v3.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

slue

Similar to gulp, but use read instead of src, and write instead of dest. Almost all of gulp's plugins are applicable for slue, except gulp-sequence, we use slue-sequence instead. Slue provide a sluepack.config.js file to bound modules and naturaly can compile reactvue and es6. If you want to compile other type file, please use slue plugins.

QQ GROUP: 738464890

slue + vue + vueRouter

sluepack.config.js

var path = require('path');
module.exports = {
    // the map of package name and it's entry file
    entry: {
        app: './test/app.js'
    },

    // output of slue
    output: {
        // the root path of your output files 
        root: path.resolve(__dirname, './dev'),
        // path of js files(relative to root)
        jsPath: './',
        // other files path(relative to root)
        staticPath: './dev/static/',

        // example http://example.com/static/
        publicPath: './dev/static/'
    },

    // external global variables
    externals: {
        'react': 'React'
    },

    // when exclude return true, the required module will be ignore
    exclude: function(opts) {
        return opts.moduleId == 'xxx';
    },

    watch: true,

    // create sourceMap when sourceMap is true, default false
    sourceMap: true,

    // compile environment,development or production
    mode: 'production',

    // the type of output files.
    module: 'cmd',

    // alias make module require shorter 
    alias: {
        components: path.join(__dirname, './components')
    },

    // extension, used to compile the type of file which  
    plugins: [{
        exts: ['.js'], // files ext names
        use: [getOnePlugin, getOnePlugin] // plugins list
    }]
};

sluepack

__sluepack__ when use sluepack.config.js,slue self define a slue task named sluepack. sluepack run after default task by default, however you can decide when to run sluepack like bottom.

slue.task('dev', ['__sluepack__'], function() {

});

const sequence = require('slue-sequence');
slue.task('dev', sequence(['clean', '__sluepack__', 'less']));

API

read by provide one or a array list of glob, to read file by stream.

const slue = require('slue');
const transformObj = require('slue-stream').transformObj;
slue.read('./test/a.js').pipe(transformObj(function(obj, env, cb) {
    cb(null, obj);
})).pipe(slue.write('./test/park'))

write write the stream piped files.

const slue = require('slue');
const slueStream = require('slue-stream').transformObj;
slue.read('./test/a.js').pipe(transformObj(function(obj, env, cb) {
    cb(null, obj);
})).pipe(slue.write('./test/park'))

watch when some file change, to do something.

const slue = require('slue');
let watcher = slue.watch(allFile);
watcher.on('change', function(filePath, stat) {
        
});

task define a task.

const Bluebird = require('bluebird');
// define task a rely b.
slue.task('a', ['b'], function() {
    return new Bluebird(function(resolve) {
        console.log('task: c');
        resolve();
    });
});

injectVars inject slue.vars into file.

Inject vars into some file.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>TDNS平台</title>
</head>
<body>
    <script src="<%= slue.vars.app %>"></script>
</body>
</html>

Create vars and call slue.injectVars to inject vars into one file.

const slue = require('slue');
const slueVars = require('slue-vars');
slue.task('less', function() {
    return slue.read(`./src/**/all.less`)
        .pipe($.less())
        .pipe(slueVars(function() {
            return {
                a: 'a',
                b: 'b'
            }
        }))
        .pipe($.postcss(processors))
        .pipe(slue.write(`./${env}`));
});
slue.task('useHtml', () => {
    return slue.injectVars('./src/index.html').pipe(slue.write('./dev'));
});
slue.task('dev', $.sequence(['less', 'useHtml']));

If your entry like this, you can get variable slue.vars.app

    entry: {
        app: './src/main.js'
    }

How to write a slue plugin

const slueStream = require('slue-stream');
module.exports = function() {
    return slueStream.transformObj(function(file, env, cb) {
        // handle file
        cb(null, file);
    });
}
const through2 = require('through2');
module.exports = function() {
    return through2.obj(function(file, env, cb) {
        // handle file
        cb(null, file);
    });
}

Events

read by provide one or a array list of glob, to read file by stream.

const slue = require('slue');
const transformObj = require('slue-stream').transformObj;
slue.on('sluepack.watcher.change', function() {
    console.log('sluepack.watcher.change');
});
3.0.2

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.5.21

4 years ago

2.5.20

5 years ago

2.5.19

5 years ago

2.5.18

6 years ago

2.5.17

6 years ago

2.5.15

6 years ago

2.5.16

6 years ago

2.5.14

6 years ago

2.5.13

6 years ago

2.5.12

6 years ago

2.5.11

7 years ago

2.5.10

7 years ago

2.5.9

7 years ago

2.5.8

7 years ago

2.5.7

7 years ago

2.5.6

7 years ago

2.5.5

7 years ago

2.5.4

7 years ago

2.5.3

7 years ago

2.5.2

7 years ago

2.5.1

7 years ago

2.5.0

7 years ago

2.4.12

7 years ago

2.4.11

7 years ago

2.4.10

7 years ago

2.4.9

7 years ago

2.4.8

7 years ago

2.4.7

7 years ago

2.4.6

7 years ago

2.4.4

7 years ago

2.4.5

7 years ago

2.4.3

7 years ago

2.4.2

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.9

7 years ago

2.3.8

7 years ago

2.3.7

7 years ago

2.3.6

7 years ago

2.3.5

7 years ago

2.3.4

7 years ago

2.3.3

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.9

7 years ago

2.2.8

7 years ago

2.2.7

7 years ago

2.2.6

7 years ago

2.2.5

7 years ago

2.2.4

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.9

7 years ago

2.1.8

7 years ago

2.1.7

7 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.9

7 years ago

2.0.8

8 years ago

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.9

9 years ago

1.1.8

9 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago