[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Implement a custom rollup plugin to properly leverage browsersync #372

Open
david-poindexter opened this issue May 5, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@david-poindexter
Copy link
Member

Is your feature request related to a problem?

Browsersync does not work perfectly with rollup out of the box.

Describe the solution you'd like

We'll need to implement a custom plugin to handle this capability. We'll leverage the one below from the DNN 10 theme Aperture as inspiration.

import bs from "browser-sync";
import { Plugin } from "rollup";
const browserSync = bs.create("rollup");

type RollupPluginBrowserSync = (options?: bs.Options) => Plugin;

const browsersync: RollupPluginBrowserSync = (browsersyncOptions) => 
{
    return {
        name: "browsersync",
        writeBundle: function(options){
            if (!browserSync.active){
                browserSync.init(browsersyncOptions || {server: "."});
            } else {
                browserSync.reload(options.file || "");
            }
        }
    }
};

export default browsersync;

Describe alternatives you've considered

n/a

Additional context

Thank you to @valadas who wrote the initial version of this custom plugin and that was used as inspiration within the DNN 10 theme Aperture.

@david-poindexter david-poindexter added the enhancement New feature or request label May 5, 2024
@david-poindexter david-poindexter added this to the 4.0.0 milestone May 5, 2024
@david-poindexter david-poindexter self-assigned this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant