Configuration 如何仅对一个文件禁用模块包装
我想避免在我的index.html上出现Configuration 如何仅对一个文件禁用模块包装,configuration,brunch,Configuration,Brunch,我想避免在我的index.html上出现require('app'),我该如何实现这一点 我想使用正则表达式,但我对它们不是很熟练,关于配置的文档对我来说也不是很清楚…您需要使用模块.wrapper部分 modules: wrapper: (path, data) -> return "#{data}" if /jquery/i.test(path) or /vendor/i.test(path) or /node_modules/i.test(path) module
require('app')
,我该如何实现这一点
我想使用正则表达式,但我对它们不是很熟练,关于配置的文档对我来说也不是很清楚…您需要使用
模块.wrapper
部分
modules:
wrapper: (path, data) ->
return "#{data}" if /jquery/i.test(path) or /vendor/i.test(path) or /node_modules/i.test(path)
moduleName = exports.config.modules.nameCleaner(path.replace(new RegExp('\\\\', 'g'), '/')).replace(/\.\w+$/, '')
'require.register("' + moduleName + '", function(exports, require, module) {\n' + data + '\n});\n\n'
这模拟了早午餐1.7.13中的commonjs包装。它不包装jquery
,供应商
,节点模块
模块,也不包装所有其他模块
使用早午餐源代码中的代码复制/粘贴清除moduleName。我并没有找到重用那个代码的方法。您始终可以从node\u modules\brunch\lib\helpers.js:cleanModuleName
和node\u modules\brunch\lib\helpers.js:getModuleWrapper
函数复制/粘贴它
可以使用比较工具创建返回的字符串。我只是比较了使用自定义函数和标准函数生成的代码,并使它们相似。您只需使用
模块
配置即可禁用它。
请参见下面的示例:
module.exports = config:
modules:
definition: false
wrapper: false
files:
javascripts: joinTo: 'app.js'
stylesheets: joinTo: 'app.css'
这样,您的JavaScript文件将保持原样。您找到答案了吗?