-
Notifications
You must be signed in to change notification settings - Fork 32
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
change handlebars and css transport style #75
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,10 @@ module.exports = function(grunt) { | |
paths: ['sea-modules'], | ||
|
||
idleading: '', | ||
alias: {}, | ||
alias: { | ||
// importstyle: 'pandora/importstyle/1.0.0/importstyle', | ||
// handlebars: 'gallery/handlebars/1.3.0/handlebars-runtime' | ||
}, | ||
|
||
// create a debug file or not | ||
debug: true, | ||
|
@@ -33,18 +36,37 @@ module.exports = function(grunt) { | |
// define parsers | ||
parsers: { | ||
'.js': [script.jsParser], | ||
'.css': [style.cssParser], | ||
'.css': [style.css2jsParser], | ||
'.html': [text.html2jsParser], | ||
'.json': [json.jsonParser], | ||
'.tpl': [template.tplParser], | ||
'.handlebars': [template.handlebarsParser] | ||
}, | ||
|
||
// for styles | ||
css: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个应该是 css2js 吧 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 就是 css,指的是文件后缀名,与后面的 handlebars 一个道理。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里的 css 是指转换 css 文件,css2js 是将 css 转换成 js There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. css 后的一个 key 是 handlebars, 你的理解,handlebars 指的是 parser ? |
||
template: [ | ||
'define(\'%s\', [\'%s\'], function(require, exports, module) {', | ||
'var importStyle = require(\'%s\');', | ||
'module.exports = function() {', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @afc163 这个有什么建议,我觉得返回一个函数也挺好,可以控制加载样式的时间,而不是执行就加载。 |
||
'importStyle(\'%s\', \'%s\');', | ||
'};', | ||
'});' | ||
].join('\n') | ||
}, | ||
|
||
// for handlebars | ||
handlebars: { | ||
id: 'gallery/handlebars/1.0.2/runtime', | ||
knownHelpers: [], | ||
knownHelpersOnly: false | ||
knownHelpersOnly: false, | ||
template: [ | ||
'define(\'%s\', [\'%s\'], function(require, exports, module) {', | ||
'var Handlebars = require(\'%s\');', | ||
'module.exports = Handlebars.template(', | ||
'%s', | ||
');', | ||
'})' | ||
].join('\n') | ||
}, | ||
|
||
// output beautifier | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
define("a-debug.css", [], function() { | ||
seajs.importStyle("body{color:#fff}"); | ||
define("a-debug.css", [ "pandora/importstyle/1.0.0/importstyle-debug" ], function(require, exports, module) { | ||
var importStyle = require("pandora/importstyle/1.0.0/importstyle-debug"); | ||
module.exports = function() { | ||
importStyle("body{color:#fff}", "a.css"); | ||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
define("a.css", [], function() { | ||
seajs.importStyle("body{color:#fff}"); | ||
define("a.css", [ "pandora/importstyle/1.0.0/importstyle" ], function(require, exports, module) { | ||
var importStyle = require("pandora/importstyle/1.0.0/importstyle"); | ||
module.exports = function() { | ||
importStyle("body{color:#fff}", "a.css"); | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个为什么改了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在我目前参与的基于 seajs 的项目中,全部都是用 css2jsParser + import-style ,像用
handlebars
一样用import-style
。css 的其它处理,都交给less(或 sass)。
所以我将默认改为css2jsParser。