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

problem while serving audio/video files #53

Open
htshah opened this issue Jan 22, 2020 · 2 comments
Open

problem while serving audio/video files #53

htshah opened this issue Jan 22, 2020 · 2 comments

Comments

@htshah
Copy link

htshah commented Jan 22, 2020

The plugin does not set desired headers for audio/video files.

Expected Headers:

Accept-Ranges: bytes
Content-Length: 489468
Content-Range: bytes 0-489467/489468
Content-Type: audio/mpeg

Received Headers:

Connection: keep-alive
Content-Type: audio/mpeg
Date: Wed, 22 Jan 2020 10:46:48 GMT
Transfer-Encoding: chunked
@thgh
Copy link
Owner

thgh commented Jan 26, 2020

Do you mind reviewing #42?

You could also consider using https://www.npmjs.com/package/rollup-plugin-serve-range

@maltoze
Copy link

maltoze commented Mar 1, 2022

I found a solution by using serve-handler.

// custom serve plugin
import handler from 'serve-handler';
import http from 'http'

function serve(options = { contentBase: '', port: 1234 }) {
  const server = http.createServer((request, response) => {
    return handler(request, response, { public: options.contentBase });
  });

  server.listen(options.port);
  server.on('error', (e) => {
    console.error(e);
  });
  return { name: 'serve' };
}

// rollup.config.js
export default  {
    input: 'src/index.ts',
    plugins: [
      typescript(),
      commonjs(),
      serve({
        contentBase: 'test/',
      }),
      livereload(),
    ],
    output: {
      file: 'test/dist/bundle.js',
      format: 'umd',
      name: 'bundleName',
    },
};

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

3 participants