Giter Club home page Giter Club logo

rollup-plugin-dev's People

Contributors

beramos avatar pearofducks avatar rothcold avatar zerowalker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rollup-plugin-dev's Issues

server.address() can be null and that crashes the plugin

I found that server.address() can be null and that crashes the plugin and rollup.

OS: macOS 10.14.6
NodeJS: 8.x

Proposed solution:

const printListenInfo = (server) => {
  const address = server.address();
  if (address) {
    address.hostname = address.address;
    const a = url.format(address);
    notice("listening on", color.bold(color.green(`http://${a}`)));
  } else {
    notice("listening on", color.bold(color.red(`unknown`)));
  }
};

Websockets proxying?

Thanks for this great plugin. I switched from trunk to rollup and use this plugin since rollup-plugin-serve doesn't support API proxying.

Does this plugin also support WebSocket proxying (like trunk or browsersync), or is it planned? :)
That would be great!

For that, it would be nice to support websockets also if they are served on a different port than the API.

Update Proxy to koa-http2-proxy for URL rewrite support

Consider updating the proxy dependency to koa-http2-proxy to support pathRewrite. I was able to swap out the import and it "just worked", but the docs and such may need updated, and it may break backwards compatability.

404s from backend proxy shouldn't fallback to spa

The title says it all!
When we get a 404 response from a proxied backend, it should not fall back to index.html even when spa: true.

A backend server often returns a 404 response when it fails to find some resource. This response is often used by an SPA frontend to show the info in a nice format. We don't want such a request to fallback to an HTML file (with 200 response).

It'll be very helpful if you can either make it the default behaviour to not to fallback from proxied responses, or maybe add a new flag that can turn on this ability.

Thank you for this very helpful plugin!

Simulate multiple domains

Hi,
I am trying to setup a dev environment for developing widgets. In the book Third Party JavaScript They describe how to simulate multiple domains by modifying your hosts file and configuring Apache web server to create two virtual hosts. I was wondering if something similar is possible using the rollup-plugin-dev development server. Basically I want to serve the widget IIFE code from one domain, say widget.dev and a test html file which loads the script code on another domain, say publisher.dev. The HTML page at publisher.dev would have a <script> tag which loads the widget. Is this something that con be configured?

Usage of websockets

As this issue is closed:
#13

I wonder what's the correct method to use websockets.
Here is what I tried in my rollup.config.js:

     plugins: [
         !production && dev({
             extend: fp(async (server) => server.register(require("@fastify/websocket"))),
             basePath: '/live',
             dirs:['public'],
             onListen(server) { server.log.info('Hello world')},
             proxy: [{from: '/metadata/', to: 'http://localhost:5001/metadata/'},{from: '/temperature/', to: 'http://localhost:5001/temperature/', opts: { websocket: true}}]
         }
         ),

When trying to access the endpoint with a websocket (/temperature)
status code remains: '101 Switching Protocols'

Allow CORS?

Is there a way to set this plugin to allow CORS? I am serving a widget in dev mode from one port and want to access it from another but I get an error:
Access to font at 'http://localhost:5100/fonts/my-font.woff2' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

IPv4 support for API proxy

I switched from trunk to rollup and at first I wondered why my API proxy wasn't working.
Then I noticed:
For trunk, it only worked when my backend listened to 0.0.0.0:9000 but for rollup with this plugin it only works with IPv6 ([::]:9000).
Would it be possible to allow IPv4, too? :)

WebSocket proxying support

Is there any plans to add support for WebSocket proxying?

Something like this in config would be great:

dev: ({
  proxy: {
    '/api': [
       'wss://websocket-host',
       { wss: true }
    ],
  },
}),

Url rewrite in proxy

Hi there, looking for recipe how to rewrite url in proxy module.
In previous version(s) we had koa-http-proxy doing the job via proxyReqPathResolver.
Please advise how to rewrite url withfastify-http-proxy opts.
Thank you,
Alex

Error when use string as the only paramater

My config file is:

import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { defineConfig } from 'rollup';
import html from "@rollup/plugin-html";
import dev from "rollup-plugin-dev"

export default defineConfig({
    input: 'src/index.tsx',
    output: {
        file: "dist/bundle.js",
        format: 'esm'
    },
    plugins: [
        nodeResolve(),
        babel({
            babelHelpers: "runtime",
            exclude: /^(.+\/)?node_modules\/.+$/,
            extensions: ['.js', '.jsx', '.ts', '.tsx'],
        }),
        html(),
        dev("dist")
    ]
});

The output:

rollup v2.67.2
bundles src/index.tsx → dist/excel.js...
[!] (plugin dev-server) TypeError: Cannot use 'in' operator to search for 'proxy' in dist
TypeError: Cannot use 'in' operator to search for 'proxy' in dist
    at Object.deprecate (/***/node_modules/rollup-plugin-dev/dist/index.cjs:195:15)
    at Object.writeBundle (/***/node_modules/rollup-plugin-dev/dist/index.cjs:204:27)
    at /***/node_modules/rollup/dist/shared/rollup.js:22801:37
    at async Promise.all (index 0)
    at handleGenerateWrite (/***/node_modules/rollup/dist/shared/rollup.js:23627:9)
    at async Promise.all (index 0)
    at Task.run (/***/node_modules/rollup/dist/shared/watch.js:233:32)
    at Watcher.run (/***/node_modules/rollup/dist/shared/watch.js:160:13)

when set to {dirs: ["dist"]}, works well.

proxy not working

  • "rollup-plugin-dev": "^1.1.3",
  • I have working REST endpoint: http://localhost:8080/analizator/api/version
{
 entity: "2.4-SNAPSHOT git-branch:svelteGUI git-commit:dec48f7"
}
  • in rollup.config.js I add
import dev from 'rollup-plugin-dev'

dev({
	dirs: ['public'],
	port: 5000,
	host: 'localhost',
	proxy: {
		'/api/*': 'http://localhost:8080/analizator'
	}
})

None of API calls work

[2021-05-08 13:40:43] waiting for changes...
⚡︎dev-server listening on http://127.0.0.1:5000
[2021-05-08 13:40:47] GET / • 200 12ms
[2021-05-08 13:40:47] GET /build/bundle.css • 200 2ms
[2021-05-08 13:40:47] GET /build/bundle.js • 200 2ms
[2021-05-08 13:40:48] GET /api/version • 404 19ms
[2021-05-08 13:40:48] GET /api/queries/ • 404 5ms
[2021-05-08 13:44:07] GET /api/ciscoStatus • 404 12ms
[2021-05-08 13:44:07] GET /api/ciscoStatus • 404 8ms
[2021-05-08 13:44:10] GET /api/queries/ • 404 4ms
[2021-05-08 13:49:08] GET /api/ciscoStatus • 404 4ms

dist/index.cjs seems to have ?? in it causing error

Tried to upgrade to the latest version of this package (from 1) and ran into:

[!] SyntaxError: Unexpected token '?'
...
    const resolvedPort = await getPort__default["default"]({ host: (config.host ?? '127.0.0.0'), port: [config.port, ...getPort__default["default"].makeRange(8081, 9000)] });

The listening task was run twice

config:

  plugins.push(dev({ 
    port: 9000,
    dirs: ['examples', 'dist'] ,
    proxy:[{ from: '/pwd-sm2', to: 'http://localhost:8080/pwd-sm2' }]
  }));

output:

[2021-12-28 13:51:06] ⚡︎dev-server proxying from /pwd-sm2 to http://localhost:8080/pwd-sm2
[2021-12-28 13:51:06] ⚡︎dev-server serving /Users/xuxihai/csii/csii-pwdctrl-h5/examples
[2021-12-28 13:51:06] ⚡︎dev-server serving /Users/xuxihai/csii/csii-pwdctrl-h5/dist
[2021-12-28 13:51:06] ⚡︎dev-server listening on http://127.0.0.1:9000
[2021-12-28 13:51:06] ⚡︎dev-server proxying from /pwd-sm2 to http://localhost:8080/pwd-sm2
[2021-12-28 13:51:06] ⚡︎dev-server serving /Users/xuxihai/csii/csii-pwdctrl-h5/examples
[2021-12-28 13:51:06] ⚡︎dev-server serving /Users/xuxihai/csii/csii-pwdctrl-h5/dist
[2021-12-28 13:51:06] ⚡︎dev-server listening on http://127.0.0.1:8081

I compared rollup-plugin-serve with rollup-plugin-dev. difference:

rollup-plugin-serve
rollup-plugin-dev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.