首页 > 解决方案 > 使用汇总保留独立评论

问题描述

我正在尝试使用汇总保留尾随的独立评论。我简要浏览了使用插件扩展汇总或深入研究 AST,但我正在寻找可能的解决方案的指导。

输入

// Some comment

const foo = {};

// Another comment <-- I want this to remain

export { foo };

输出

(function (exports) {
    'use strict';

    // Some comment

    const foo = {};

    exports.foo = foo;

    return exports;

}({}));

汇总配置

export default [
  {
    input: "src/index.js",
    plugins: [],
    output: {
      file: "dist/index.js",
      format: "iife",
      name: "foo"
    },
    treeshake: false
  }
];

标签: rollupjs

解决方案


推荐阅读