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

纯css模块问题 #56

Open
myseawp opened this issue Mar 2, 2016 · 0 comments
Open

纯css模块问题 #56

myseawp opened this issue Mar 2, 2016 · 0 comments
Assignees

Comments

@myseawp
Copy link

myseawp commented Mar 2, 2016

我看文档里描述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的组件

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