Brunch 配置文件 : what is the difference between exports. config 和 module.exports = config?

标签 brunch

在 Brunch 网站的指南中,他们按照以下方式启动配置文件 module.exports = config:,但是您可以在同一网站上找到的大多数框架使用另一种语法 导出.config = .

它们有什么区别?都是 javascript CommonJS 模块吗?

最佳答案

我直接查看了文档:module node documentation 。我一开始就应该做的事情:)

The exports variable that is available within a module starts as a reference to module.exports. As with any variable, if you assign a new value to it, it is no longer bound to the previous value.

If you want the root of your module's export to be a function (such as a constructor) or if you want to export a complete object in one assignment instead of building it one property at a time, assign it to module.exports instead of exports.

最后,他们说:

As a guideline, if the relationship between exports and module.exports seems like magic to you, ignore exports and only use module.exports.

瞧瞧!

关于Brunch 配置文件 : what is the difference between exports. config 和 module.exports = config?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34860592/

相关文章:

javascript - Brunch:如何将 vendor 代码包装在 AMD 模块中?

npm - 不要将所有 css 文件编译成 app.css 并在需要时手动包含其中一些

javascript - 有没有办法在早午餐中设置智能/动态 'joinTo' 输出文件?

javascript - 如何在 Phoenix 中使用 d3.js?

javascript - Node.js - "Uncaught Error: Cannot find module "redis“”

javascript - Brunch - 需要应用程序目录之外的模块

node.js - 将 brunch 与 Node.js 模块结合使用

javascript - BrowserSync 与导致错误的分析脚本

jquery - 在 Brunch 2.8 中加载 JQuery 插件

javascript - 如何在早午餐中加载 Foundation 6 JS?