rollup-plugin-serve icon indicating copy to clipboard operation
rollup-plugin-serve copied to clipboard

add major features from webpack-dev-server

Open pkit opened this issue 5 years ago • 4 comments

  • compress
  • proxy
  • before
  • after
  • historyApiFallback (object format)
  • serveIndex
  • headers

The end goal is to make sure it can run react-scripts config (almost) unmodified

pkit avatar Feb 21 '20 13:02 pkit

This looks promising, but I don't have the time to review this completely so I hope somebody else can review.

I released the PR as [email protected]

thgh avatar Feb 26 '20 03:02 thgh

A happy user of [email protected] here. I'm especially happy about the directory indexes, because I have several development pages in my project and I like to navigate to them in the browser. My configuration:

  serve({
    open: false,
    port: 8080,
+   contentBase: __dirname, // I have rollup config in the project root
+   serveIndex: true,
  })

If I don't add the contentBase, it'll fail:

[!] TypeError: root path required
TypeError: root path required
    at Function.serveStatic [as static] (/Users/ferdipr/Sources/gitlab/ot-web-components/node_modules/serve-static/index.js:40:11)
    at /Users/ferdipr/Sources/gitlab/ot-web-components/node_modules/rollup-plugin-serve/dist/index.cjs.js:189:58
    at Array.forEach (<anonymous>)
    at Object.contentBaseFiles (/Users/ferdipr/Sources/gitlab/ot-web-components/node_modules/rollup-plugin-serve/dist/index.cjs.js:188:29)
    at /Users/ferdipr/Sources/gitlab/ot-web-components/node_modules/rollup-plugin-serve/dist/index.cjs.js:272:22
    at Array.forEach (<anonymous>)
    at Object.serve [as default] (/Users/ferdipr/Sources/gitlab/ot-web-components/node_modules/rollup-plugin-serve/dist/index.cjs.js:271:42)
    at Object.<anonymous> (/Users/ferdipr/Sources/gitlab/ot-web-components/rollup.config.js:81:46)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.require.extensions.<computed> [as .js] (/Users/ferdipr/Sources/gitlab/ot-web-components/node_modules/rollup/dist/shared/loadConfigFile.js:621:20)

The default contentBase: '' worked earlier to serve the content of the current directory. You might want to send process.cwd() to the serve-static, so that it wouldn't fail with the default configuration right away.

prantlf avatar Dec 07 '22 10:12 prantlf

This feature was included in 2.0.0-beta.0, but it didn't make it to 2.0.0. Are there any plans to include it in an upcoming version? Thank you!

prantlf avatar Jan 09 '23 16:01 prantlf

2.0.2 was released without this feature. Are you going to accept ii? Or do you want to close this PR and wait for a different one?

prantlf avatar Mar 30 '23 06:03 prantlf