Brunch how to disable RequireJS module wrapping

。_饼干妹妹 提交于 2019-12-03 11:26:24

The ability to disable the module wrapping was just recently added in https://github.com/brunch/brunch/commit/ec158cffd1b66d5db2093cf766000673aa0dd3a5

I dont believe the release w/ these features is on npm yet but you could just re-install brunch from the github repo

Once you do that Brunch, set jsWrapper to 'raw' in your config.coffee

Something like this...

exports.config =
  jsWrapper: 'raw'
  files:
    javascripts:
      defaultExtension: 'js'
      joinTo:
        'javascripts/app.js': /^app/
        'javascripts/vendor.js': /^vendor/

'brunch b' and the wrapping code should disappear

This has changed to a module configuration now, as far as I can see: https://github.com/brunch/brunch/blob/stable/docs/config.md#modules

exports.config =
  paths:
    ...
  files:
    ...
  modules:
    wrapper: false
    definition: false

As of (almost) 2017 Jan, it is imperative to declare npm enabled to false along with module settings. It took me a while to find out, though. (Found this via a GitHub issue). Hope this helps. Cheers.

Here is a working config file:

// See http://brunch.io for documentation.
module.exports = {
    files: {
      javascripts: {
        joinTo: {
          '/js/app.js': /^app/,
          '/js/vendor.js': /^(?!app)/
        }
      },
      stylesheets: {
        joinTo: 'css/app.css'
      }
    },

    paths: {
      public: '/priv/static'
    },

    npm: {
      enabled: false
    },

    modules: {
      wrapper: false,
      definition: false
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!