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

require("css文件")外部样式打包后不显示 #993

Closed
cxc3214 opened this issue Oct 20, 2013 · 5 comments
Closed

require("css文件")外部样式打包后不显示 #993

cxc3214 opened this issue Oct 20, 2013 · 5 comments

Comments

@cxc3214
Copy link

cxc3214 commented Oct 20, 2013

define(function(require,exports,module){
require("./1.css"); //自定义样式
require("otherlibUrl/1.css"); //外部样式
})
上面两个 在src 调用时 两个文件都能加载
但是使用SPM打包后 只能显示 打包后的结果文件

define("apps/test/css", ["./1.css"], function(e) {
e("./1.css"), e("otherlibUrl/1.css")
}), define("apps/test/1.css", [], function() {
seajs.importStyle("body{background-color:#abc123}")
});

请教两个问题
1.seajs 引入css文件是否只能使用 style插件?
2.为什么使用源文件可以自动加载css文件而打包后文件却不能加载?

@lifesinger
Copy link
Member

是不是没有引入 style 插件?控制台上是否有 seajs.importStyle 不存在的报错?

@cxc3214
Copy link
Author

cxc3214 commented Oct 21, 2013

感谢回答!

style 插件引入了,打包构建后的
define("apps/test/1.css", [], function() {
seajs.importStyle("body{background-color:#abc123}")
}); 是加载了,但是
define("apps/test/css", ["./1.css"], function(e) {
e("./1.css"), e("otherlibUrl/1.css")
}),
却没有加载,与之对应的

require("otherlibUrl/1.css"); //外部样式
在没有打包构建之前是可以加载的。

就是想问下
define(function(require,exports,module){
require("./1.css"); //自定义样式
require("otherlibUrl/1.css"); //外部样式
})

define("apps/test/css", ["./1.css"], function(e) {
e("./1.css"), e("otherlibUrl/1.css")
}),

两个代码为什么一个可以一个不可以

@Aturan
Copy link

Aturan commented Oct 23, 2013

可能是grunt-contrib-concat的问题,对找不到的文件会删除掉而不是忽略
之前碰到过一次
对于线上环境页面直接引用吧

@lifesinger
Copy link
Member

嗯,是 @Aturan 说的问题。构建这一块,我们会再好好考虑下怎么简化,目前还是有点小复杂。

@cxc3214
Copy link
Author

cxc3214 commented Nov 1, 2013

thanks

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

3 participants