scrat-team / scrat

Webapp Modular Framework
http://scrat-team.github.io/
773 stars 147 forks source link

纯css模块问题 #56

Open myseawp opened 8 years ago

myseawp commented 8 years ago

我看文档里描述css也可以模块化:

使用注释中的@require xxx来标记依赖

/**
 * 引用模块
 * @require font-awesome
 *
 * 引用文件
 * @require ./bar.css
 */

.foo .fa {
    font-size: 20px;
}

但这样css还是需要依赖同名的js来完成加载。

我通过生态模块的component.json的main指定css文件,是可以自动安装纯css组件的

但是如果在components文件夹下建立组件,只放与组件同名的css文件,编译会报错,我翻了下源码:

else if(file.isMod && (file.isJsLike || file.isCssLike)){
            if(file.isJsLike){
                var match = file.subpath.match(/^\/components\/(.*?([^\/]+))\/\2\.(js|jsx)$/i);
                if(match && match[1] && !map.alias.hasOwnProperty(match[1])){
                    map.alias[match[1]] = id;
                }
            }

            if(file.requires.length){
                map.deps[id] = file;
            }

这里只处理了js模块,并没有处理纯css的模块。我觉得纯css模块也很合理啊,如果能配合less/sass就更好了,可否扩展支持纯css的组件