pearofducks / rollup-plugin-dev Goto Github PK
View Code? Open in Web Editor NEWdevelopment server for rollup with additional logging and options
License: MIT License
development server for rollup with additional logging and options
License: MIT License
If the user generates assets using @rollup/plugin-html - the server won't find these.
From the npm page:
[email protected] has been deprecated. Please use @fastify/[email protected] instead.
I only realized because errors appeared in the console.
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`)));
}
};
as mentioned.
receives access-control-*
headers and cookie header from upstream was discard
writeBundle()
will not fire yet, i.e. assets that are copied there will be unavailable.
And index.html
is an asset...
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.
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.
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!
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?
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'
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.
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? :)
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 }
],
},
}),
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
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.
It is stated in https://github.com/pearofducks/rollup-plugin-dev/releases/tag/v2.0.0
that spa option now goes into dirs.
It is really hard to understund how exactly it should be specified and some example would be very nice.
http://localhost:8080/analizator/api/version
{
entity: "2.4-SNAPSHOT git-branch:svelteGUI git-commit:dec48f7"
}
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
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)] });
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:
Some plugins like rollup-plugin-progress
do not play well together with rollup-plugin-dev
since they are both trying to output on console. The solution could be to make silent
to also hide plugin logs.
Can I customize printListenInfo
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.