将新的 apostrophe-cms 项目与现有的 Gulp.js 项目相结合

Combining new apostrophe-cms project with existing Gulp.js project

我最近在搜索 Wordpress/TYPO 3 替代方案时发现了 Apostrophe CMS,我必须说,我印象非常深刻!不用说,我也对这个庞大框架中的所有内容感到不知所措。

所以我的问题是:如何以最有效的方式将我现有的 gulp 项目与热重载、sass-样式表等与 Apostrophe 结合起来?

我认为 Apostrophe 可以很好地配合我已经使用的技术,但似乎也没有关于如何执行此类操作的文档。

提前致谢!

您可以将自定义前端源文件放在任何地方(srcfrontend 在根目录中很受欢迎)。您将使用 self.pushAsset in the module where you've output the built assets. There's some more about this in the docs for the apostrophe-assets module 推送它。 (对于新开发者来说,这当然可以做得更好)

正如那里所说,不特定于特定模块的前端资产(例如,自定义轮播小部件的播放器 JS)仍应放在您拥有的模块中。 assets 模块是一个不错的选择(您必须像其他模块一样在 app.js 中声明它)。所以你可能有这样的东西:

// in lib/modules/assets/index.js
module.exports = {
  construct: function(self, options) {
    self.pushAsset('stylesheet', 'styles', { when: 'always' });
  }
}

styles 因为 name 参数表示文件名为 styles.css(您的构建输出文件)。由于类型是stylesheet,这个文件位于资产模块public CSS 目录中,lib/modules/assets/public/css/styles.css。这在上面链接的 pushAsset 文档中有所介绍。