Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

基于js文件的依赖合并 #40

Open
small-joker opened this issue Feb 4, 2016 · 3 comments
Open

基于js文件的依赖合并 #40

small-joker opened this issue Feb 4, 2016 · 3 comments

Comments

@small-joker
Copy link

想法:
基于seajs的依赖合并是基于html页面开始的,我想不管html页面,直接基于页面js文件,通过页面js文件里的依赖关系把文件合并。

目录规范:


- pro
- --json
- --static
- ----| images
- ----| js
- ------| pages
- ------| plugin
- ------| widget
- ----| css
- --view

fis-conf.js代码:

fis.set('project.files', ['/static/js/pages/**.js']);

fis.match('*.js', {
  isMod: true
});

fis.match("/static/js/core/sea.js",{
  isMod:false
});

fis.hook('cmd', {
  baseUrl: './static/',

  paths: {
    "jquery":"js/core/jquery.js",
    "validform": "js/plugins/validform/core.source"
  }
});

fis.match("*",{
  deploy:fis.plugin("local-deliver",{
    to:"../prod/pro1"
  })
});

fis.match('::packager', {
  postpackager: fis.plugin('loader', {
      allInOne: {
        includeAsyncs: true,
        ignore: ['/static/js/core/sea.js']
      }
    })
});

原页面js代码:

define(function(require, exports, module) {
    require("jquery");
    require("validform");
});

生成的页面js代码

define('static/js/pages/test', ["static/js/core/jquery", "static/js/plugins/validform/core.source"], function(require, exports, module) {
    require("static/js/core/jquery");
    require("static/js/plugins/validform/core.source");
});

没有根据require把jquery与validform两个文件合并进来。

当我基于html

fis.set('project.files', ['*.html']);

这样的时候就可以把jquery与validform合并进来。

请指教,谢谢。

@small-joker
Copy link
Author

这个不行的吗?

@2betop
Copy link
Contributor

2betop commented Feb 19, 2016

那个合并是 loader 插件分析页面资源后自动合并的,注意是页面。

如果你的项目没有 html, 而是直接想把 js 合并起来,你可以用这个插件实现。https://github.com/fex-team/fis3-packager-deps-pack

@small-joker
Copy link
Author

@2betop thx,我先看下那个插件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants