Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Configuration 如何仅对一个文件禁用模块包装_Configuration_Brunch - Fatal编程技术网

Configuration 如何仅对一个文件禁用模块包装

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

我想避免在我的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)
    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文件将保持原样。

您找到答案了吗?