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

hot reload newly added entry point #11

Closed
hellofantastic opened this issue Jun 27, 2020 · 2 comments
Closed

hot reload newly added entry point #11

hellofantastic opened this issue Jun 27, 2020 · 2 comments

Comments

@hellofantastic
Copy link

hellofantastic commented Jun 27, 2020

Let me say pretty marvellous repo, I've learned a bit about webpack.

I decided to add another entry point in the webpack.config

  indexScript: path.join(__dirname, 'src', 'index.jsx'),

inside this file is this:
it makes use of InboxSDK.js
it adds functionality to various parts of Gmail web UI and accepts React nicely for UI building
I added it to webpack config and it gets copied over where it needs to be

import React from 'react';
import ReactDOM from 'react-dom';

const TestFeature = () => <div>boo hoo</div>; //editing these components does not trigger a reload
const Sidebar = () => <div>Boo hoo hoo</div>;

InboxSDK.load(2, 'app-id').then((sdk) => {

    //Add Compose new window bottom toolbar
    sdk.Compose.registerComposeViewHandler((composeView) => {
        composeView.addButton({
            title: "Test Feature",
            iconUrl: chrome.runtime.getURL('images/template-list-256x256.svg'),
            hasDropdown: true,
            onClick: (event) => {
                ReactDOM.render(<TestFeature />, event.dropdown.el);
            }
        });
    });

    //Sidebar 
    let el = document.createElement('div')
    ReactDOM.render(<Sidebar />, el)

    const panelView = sdk.Global.addSidebarContentPanel({
        title: 'Sidebar test',
        iconUrl: 'sidebarlogo.png',
        el: el
    })

    //Auto Open sidebar
    //Mainly handle for development
    panelView.then(function (panel) {
        panel.open()
    });

});

Everything loads up and works except no magic reload for indexScript
When I save indexScript the webserver recompiles build updates but I need to refresh extension page setting and then reload browser

Any insight much appreciated

@hellofantastic hellofantastic changed the title reload newly added entry point hot reload newly added entry point Jun 27, 2020
@hellofantastic
Copy link
Author

Okay so reading this (why?) from readme.
Sorry for being dense but does this mean you can't get HMR with content scripts?

@hellofantastic
Copy link
Author

hellofantastic commented Jun 28, 2020

Not exactly but I kept reading and this gets content scripts reloaded,
samuelsimoes/chrome-extension-webpack-boilerplate#4 (comment)
it forces the browser to reload so not HMR just R

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant