Skip to content

feat: add new modifyHTML hook#5145

Merged
chenjiahan merged 2 commits intomainfrom
modify_html_0501
May 2, 2025
Merged

feat: add new modifyHTML hook#5145
chenjiahan merged 2 commits intomainfrom
modify_html_0501

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

Add a new modifyHTML hook to modify the final HTML content.

  • The hook receives a context object that contains the HTML content, and you can return a new HTML string to replace the original one.
  • This hook is triggered after the modifyHTMLTags hook.

Example:

const myPlugin: RsbuildPlugin = {
  name: 'my-plugin',
  setup(api) {
    api.modifyHTMLTags((tags) => {
      tags.bodyTags.push({
        tag: 'div',
        children: 'foo',
      });
      return tags;
    });
    api.modifyHTML((html) => {
      return html.replace('foo', 'bar');
    });
  },
};

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link
Copy Markdown

netlify bot commented May 1, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit f908fed
🔍 Latest deploy log https://app.netlify.com/sites/rsbuild/deploys/68141a49ec9f7900086a1c13
😎 Deploy Preview https://deploy-preview-5145--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 67 (🔴 down 17 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@chenjiahan chenjiahan merged commit a7eb4c1 into main May 2, 2025
11 checks passed
@chenjiahan chenjiahan deleted the modify_html_0501 branch May 2, 2025 05:37
This was referenced May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant