更新:对于任何有兴趣将 Brunch 与 AngularJS 我整理了一个种子项目 angular-brunch-seed
Update: For anyone interested in using Brunch with AngularJS I've put together a seed project angular-brunch-seed
我正在使用 Brunch 和 AngularJS.AngularJS 提供了一个模块系统,因此使用 commonJS/AMD 导入文件的需要是多余的.是否可以对 /app
目录中的文件禁用此功能?本质上,我希望它像 /vendor
目录一样编译未更改的文件.
I'm using Brunch with AngularJS. AngularJS provides a module system so the need for importing file using commonJS / AMD is redundant. Is it possible to disable this feature for files in the /app
directory? Essentially I would like it to compile files unaltered like it does for the /vendor
directory.
所以首选的结果是:
joinTo:
'js/app.js': /^app/
'js/vendor.js': /^vendor/
js/app.js
和 js/vender.js
都包含来自各个文件夹的编译文件,但都没有打包.
With both js/app.js
and js/vender.js
containing compile files from each respective folder, but neither wrapped.
有人有什么想法吗?
更新语法从@jcruz 回答时发生了变化.这是现在执行此操作的方法.
UPDATE The syntax has changed from when @jcruz answer. Here's the way to do this now.
最后我选择了@jcruz 答案的修改版本.
In the end I went with a modified version of @jcruz answer.
exports.config =
modules:
definition: false
wrapper: (path, data) ->
"""
(function() {
'use strict';
#{data}
}).call(this);
"""
files:
javascripts:
defaultExtension: 'coffee'
joinTo:
'js/app.js': /^app/
'js/vendor.js': /^vendor/
默认情况下,原始"包装器不包括 coffeescript 的标准包装器.通过将 jsWrapper 设置为:
By default the "raw" wrapper does not include coffeescript's standard wrapper. By setting jsWrapper to:
wrapper: (path, data) ->
"""
(function() {
'use strict';
#{data}
}).call(this);
"""
文件将按预期包装.
最近刚刚在 https://github.com/brunch/brunch/commit/ec158cffd1b66d5db2093cf766000673aa0dd3a5
我不相信带有这些功能的版本在 npm 上,但你可以从 github repo 重新安装早午餐
I dont believe the release w/ these features is on npm yet but you could just re-install brunch from the github repo
完成早午餐后,在 config.coffee 中将 jsWrapper 设置为raw"
Once you do that Brunch, set jsWrapper to 'raw' in your config.coffee
这样的……
exports.config =
jsWrapper: 'raw'
files:
javascripts:
defaultExtension: 'js'
joinTo:
'javascripts/app.js': /^app/
'javascripts/vendor.js': /^vendor/
'brunch b' 和包装代码应该消失
'brunch b' and the wrapping code should disappear
这篇关于早午餐如何禁用 RequireJS 模块包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!