javascript - fis3 打包问题
PHP中文网
PHP中文网 2017-04-10 17:58:49
[JavaScript讨论组]

使用fis3打包, 打包顺序问题,目的是使打包出来framework.js里面顺序与配置顺序一样

  1. 设置 packOrder

  2. 声明依赖

//声明依赖
var app = angular.module('test',[
    "ngTouch",
    "ui.router"
]); //要不要这个依赖 打包结果一样
 ......

fis.match(createGlobPatternSet([
        'framework/js/bower_components/angular/angular.js',
        'framework/js/bower_components/angular-ui-router/release/angular-ui-router.js'
    ]), {
        packTo: 'framework/framework.js'
    })
    .match(createGlobPatternSet([
        'framework/app.js',
        'framework/js/services/**.js',
        'framework/js/directive/**.js',
        'framework/js/filters/**.js',
        'framework/js/providers/**.js'
    ]), {
        packTo: 'framework/component.js'
    });
    
    function createGlobPatternSet(arr) {
        return "{" + arr.join(',') + "}";
    }
    
    
     .match(createGlobPatternSet([
        'framework/js/bower_components/angular/angular.js',
        'framework/js/bower_components/angular-touch/angular-touch.js',
        'framework/js/bower_components/angular-ui-router/release/angular-ui-router.js'
    ]), {
        packTo: 'framework/framework.js'
    })
    .match('framework/js/bower_components/angular/angular.js', {
      packOrder: 100
    }) //并没有影响
    
    
   
   
    .match('::package', {
    packager: fis.plugin('map', {
    'framework/framework.js': [
    'framework/js/bower_components/angular/angular.js',
    'framework/js/bower_components/angular-touch/angular-touch.js',
    'framework/js/bower_components/angular-ui-router/release/angular-ui-router.js'
    ]
    })
    })
    // 自动替换合并文件的插件
    .match('::packager', {
        postpackager: fis.plugin('loader', {
            allInOne: true
        })
    }); //依旧没有用
    
    
    
    framework.js 顺序
    ;/*!/framework/js/bower_components/angular-touch/angular-touch.js*/
    ;/*!/framework/js/bower_components/angular-ui-router/release/angular-ui-router.js*/
    ;/*!/framework/js/bower_components/angular/angular.js*/
    ......
PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(1)
PHP中文网

其实packOrder应该是这么用的

比如说我要合并one.js和two.js到all.js

fis.match('one.js',{
    packOrder:1,
    packTo:'all.js'
}).match('two.js',{
    packOrder:2,
    packTo:'all.js'
});

关于评论里说到多个文件的问题:我之前尝试过在项目从fis到fis3迁移时搞的配置

/*
 pack:{
    'all.js':[
        'one.js',
        'two.js'
    ],
    'all2.js':[
        '1.js',
        '2.js'
    ]
  }
*/
var FilePack = function(pack){
    var _this = this;
    for(var packPath in pack){
        var filesPath = pack[packPath];
        filesPath.forEach(function(e, i){
            _this.match(e,{
                packOrder:i,
                packTo : packPath
             });
        });
    }
    return this;
};
fis.media('prd').FilePack = fis.media('pro').FilePack = FilePack;
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号