aui / tmodjs

前端模板外置解决方案
666 stars 189 forks source link

如何排除一些文件 #21

Open bluemsn opened 10 years ago

bluemsn commented 10 years ago

tmodjs 在使用的时候,的确带来了很大的便利 但同样也出现了一些问题希望能够得到解决 例如 我在写页里的时候。有些页面或者文件夹只是做测试使用。并不想让其编译到templatejs里。因为那样会增大文件[影响速度当文件多的时候???]。 当然按Doc 上说的 可以取消掉合并combo:false 按需要的使用 但文件还是会编译到build 文件下面。而我只想要一些自己需要编译的文件 如何做呢。 可否提供一个配置 exclude 用来控制不需要的编译的文件 呢。

aui commented 10 years ago

后续考虑增加配置支持忽略文件的功能

pulo commented 10 years ago

这个功能蛮重要的~~~顶一下; 或者先简单点,支持后缀名

aui commented 10 years ago

下个版本支持。计划使用 https://github.com/isaacs/node-glob 的规则

pulo commented 10 years ago

好的 谢谢

bluemsn commented 10 years ago

@aui 有这样一个场景,目前tmodjs的打包规则是 接照amd ,cmd 类似seajs,requirejs的 define形式进行打包的, 如下: https://github.com/aui/artTemplate/blob/master/src/outro.js


// RequireJS && SeaJS
if (typeof define === 'function') {
    define(function() {
        return template;
    });

// NodeJS
} else if (typeof exports !== 'undefined') {
    module.exports = template;
} else {
    this.template = template;
}

})();

这样打包,少了很多的适用性,因为有些加载器上的define规则 不是这个样式,这样就没办法适用了,

如下;


// RequireJS && SeaJS
if (typeof define === 'function') {
    define("想在此处会有一些名称"function() {
        return template;
    });

// NodeJS
} else if (typeof exports !== 'undefined') {
    module.exports = template;
} else {
    this.template = template;
}

})();

不知道 怎么样可以做到这样的需要求,

我看了一下 tmodjs的源码,发现支持 cmd,amd,default,的那段https://github.com/aui/tmodjs/blob/master/src/AOTcompile.js#L82
我自己加了一条规则 重写了一下,但是最后发现,define的地方,还是需要修改。觉得这个地方需要在grunt或者什么地方去配置。将配置的信息加到根据需要编译文件名字来定, define('static/js/a',['template'], function(){})