在我的 grails 应用程序中,我定义了以下资源模块,其中混合了由 Less 生成的 CSS 文件和常规 CSS 文件。
responsive {
dependsOn 'jquery'
resource 'js/responsive/bootstrap.js'
resource 'css/footer.css'
resource url: 'less/style.less', attrs: [rel: "stylesheet/less", type: 'css'], bundle: 'bundle_responsive'
}
根据plugin docs , bundle: 'bundle_responsive'
应该将所有 CSS 文件捆绑在一起。当页面加载时,我看到确实只有一个 CSS 包
<link href="/summer-festivals/bundle-bundle_responsive_head.css" type="text/css" rel="stylesheet" media="screen, projection" />
但是,找不到捆绑文件,所以出现错误:
ERROR resource.ResourceMeta - Resource not found: /bundle-bundle_responsive_head.css
当然, bundle 中的所有资源都不会加载。如果我删除 bundle: 'bundle_responsive'
,所有资源都会加载,但从 Less 生成的 CSS 文件与常规 CSS 文件位于不同的包中。
如何将所有 CSS 文件捆绑在一起?
最佳答案
我没有用过这个,所以我在这里的回答纯粹是基于我阅读文档并与您的示例代码进行比较得出的。可能导致(您必须测试)的一个差异是像文档代码一样将您的 block 声明 responsive
放在单引号中,因为这可能会影响形成资源的“路径”:
不是:响应式{ ... }
但是:'responsive' { ... }
关于css - 将 Less 和 CSS 文件与 grails lesscss-resource 捆绑在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13660787/