Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rfc/issue 182 template hooks #189

Merged
merged 8 commits into from
Sep 5, 2019

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Sep 1, 2019

Related Issue

resolves #182

Summary of Changes

Updated TODOs of #188 (please review first)

  1. Created an API for injecting custom HTML into index.html for:
    • polyfills
    • analytics
  2. Added unit tests
  3. Added documentation (created Plugins nav item in header)

Screen Shot 2019-08-29 at 9 04 31 PM

Misc Thoughts / Questions / Observations

  1. I wonder if we should get rid of 404.html? Maybe it could be it's own (composite) plugin?
  2. Could introduce new hooks for manifest.json and ServiceWorkers as part of a PWA plugin (should make a ticket)

@thescientist13 thescientist13 added the RFC Proposal and changes to workflows, architecture, APIs, etc label Sep 1, 2019
<meta name='apple-mobile-web-app-capable' content='yes'/>
<meta name='apple-mobile-web-app-status-bar-style' content='black'/>

<%= htmlWebpackPlugin.options.hookSpaIndexFallback %>
Copy link
Member

@hutchgrant hutchgrant Sep 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we provide an example of usage of a hook besides the spafallback script.

e.g. If we give example for analytics, shouldn't we also give example of the hook usage within the a custom index file.

edit: custom index file I mean

<%= htmlWebpackPlugin.options.yourhook %>

Just so there's no confusion around the usage of custom hooks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. Will add.

@@ -51,6 +51,17 @@ module.exports = ({ config, context }) => {
}
];

const customHooks = Object.assign({}, ...config.plugins
.filter((plugin) => plugin.type === 'hook')
Copy link
Member

@hutchgrant hutchgrant Sep 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we give these a more specific name of hook? hooks in general we may have more types of them I'm not sure, maybe we can change that later. When I saw template hooks, I thought it would have to do with page-templates not index.

Copy link
Member Author

@thescientist13 thescientist13 Sep 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe there are two things here

  1. hooks are the API for this particular capability (injecting stuff in index.html, and so other plugin.types would be handled somewhere else because they would be doing a different thing specific to their own implementation. (e.g. in this case, we only care about plugin.type === 'hook')
  2. The name hooks / Template Hooks may not be the most direct / semantic name, so let think of something else we could try and call it instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about calling the plugin type index instead?

Copy link
Member Author

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to rename them to Index Hooks for now, just to avoid any confusion with App / Page Templates

@thescientist13 thescientist13 merged commit 11800e7 into release/0.4.0 Sep 5, 2019
@thescientist13 thescientist13 deleted the rfc/issue-182-template-hooks branch September 5, 2019 00:59
thescientist13 added a commit that referenced this pull request Oct 16, 2019
* first draft

* hooks working

* plugins docs overview and site navigation

* document template hooks

* TODO cleanup

* clean up console log

* update documentation example

* API rename and error handling tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Proposal and changes to workflows, architecture, APIs, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants