0.0.4 • Published 8 years ago

fis3-deploy-pack v0.0.4

Weekly downloads
2
License
BSD
Repository
github
Last release
8 years ago

fis3-deploy-pack

fis3 打包压缩插件

Usage

// fis-conf.js
fis.match('/usedomain/(*)', {
        release: '$1',
        domain: 'http://test.qq.com/m'
    })
    .match('/setpack/(*)', {
        pack: '$1'
    })
    .match('/notpack', {
        pack: false
    })
    .match('*', {
        deploy: [
            fis.plugin('local-deliver', {
                // ...
            }),
            fis.plugin('pack')
        ]
    });

Options

entry.defaultOptions = {
    tmp: '../.pack-tmp', // 临时文件夹

    type: 'zip', // 压缩类型, 传给archiver

    to: '../pack/pack.zip', // 输出压缩包名

    packDomain: true, // 是否打包所有包含domain属性的文件

    // 文件在压缩包中的路径
    subpath: function(file) {
        return typeof file.pack === 'string' ? file.pack : fis.util(
            (file.domain || '').replace(/^http:\/\//i, ''), 
            file.release || file.subpath
        );
    },

    // 文件内容
    content: function(file) {
        var inject = {
            version: Date.now()
        };
        return !file. _likes || !file. _likes.isHtmlLike 
            ? file.getContent()
            : (file.getContent() || '').replace(
                /(<script)/, 
                '<script>var pack = ' + JSON.stringify(inject) + '</script>$1'
            );
    }
}
0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago