Brunch how to disable RequireJS module wrapping(早午餐如何禁用 RequireJS 模块包装)
问题描述
更新:对于任何有兴趣将 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 模块包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:早午餐如何禁用 RequireJS 模块包装
				
        
 
            
        - 如何调试 CSS/Javascript 悬停问题 2022-01-01
 - 如何显示带有换行符的文本标签? 2022-01-01
 - 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
 - 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
 - 从原点悬停时触发 translateY() 2022-01-01
 - 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
 - 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
 - 在不使用循环的情况下查找数字数组中的一项 2022-01-01
 - 为什么我的页面无法在 Github 上加载? 2022-01-01
 - 如何向 ipc 渲染器发送添加回调 2022-01-01
 
						
						
						
						
						
				
				
				
				