Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
您可以使用文本将模板指定为依赖项!像你所展示的模块。我用小胡子模板来做到这一点。
但是 Require.js 并不明确支持 css 文件。
这是官方的解释,解释得很好:http://requirejs.org/docs/faq-advanced.html#css
编辑:2012 年 2 月。
像车把这样的模板也可以像任何其他 JS 模块一样预编译和包含http://handlebarsjs.com/precompilation.html
编辑:2015 年 8 月
如果您想要这种模块化,您应该研究一下webpack 特别是 css-loader。我使用它将 .css 文件与 .jsx 文件配对作为统一的“模块”,并在构建时将相关 CSS 提取到单个样式表中。
You can specify the template as a dependency using the text! module like you have shown. I do this with Mustache Templates.
However Require.js does not explicitly support css files.
Here is the official explanation, it's explained pretty well:http://requirejs.org/docs/faq-advanced.html#css
Edit: Feb 2012.
Templates such as handlebars can also be precompiled and included just like any other JS modulehttp://handlebarsjs.com/precompilation.html
Edit: August 2015
If you're after this sort of modularization you should look into webpack and specifically css-loader. I'm using it to pair .css files with .jsx files as a unified "module" and extract the relevant CSS into a single stylesheet at build time.
RequireJS 有一个第三方 CSS 插件,似乎运行良好: https://github.com/VIISON/需要 CSS/。
There is a third-party CSS plugin for RequireJS which seems to work well: https://github.com/VIISON/RequireCSS/.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
您可以使用文本将模板指定为依赖项!像你所展示的模块。我用小胡子模板来做到这一点。
但是 Require.js 并不明确支持 css 文件。
这是官方的解释,解释得很好:
http://requirejs.org/docs/faq-advanced.html#css
编辑:2012 年 2 月。
像车把这样的模板也可以像任何其他 JS 模块一样预编译和包含
http://handlebarsjs.com/precompilation.html
编辑:2015 年 8 月
如果您想要这种模块化,您应该研究一下webpack 特别是 css-loader。我使用它将 .css 文件与 .jsx 文件配对作为统一的“模块”,并在构建时将相关 CSS 提取到单个样式表中。
You can specify the template as a dependency using the text! module like you have shown. I do this with Mustache Templates.
However Require.js does not explicitly support css files.
Here is the official explanation, it's explained pretty well:
http://requirejs.org/docs/faq-advanced.html#css
Edit: Feb 2012.
Templates such as handlebars can also be precompiled and included just like any other JS module
http://handlebarsjs.com/precompilation.html
Edit: August 2015
If you're after this sort of modularization you should look into webpack and specifically css-loader. I'm using it to pair .css files with .jsx files as a unified "module" and extract the relevant CSS into a single stylesheet at build time.
RequireJS 有一个第三方 CSS 插件,似乎运行良好: https://github.com/VIISON/需要 CSS/。
There is a third-party CSS plugin for RequireJS which seems to work well: https://github.com/VIISON/RequireCSS/.