Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/migrate-v1-to-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,44 @@ npm i -D selfsigned@^5.0.0
# or bun add -D selfsigned@^5.0.0
```

### Removed `serve-index` support

`devServer.static.serveIndex` is removed in v2 to reduce third-party dependencies.

If you still need directory listings for a static directory, install [serve-index](https://www.npmjs.com/package/serve-index) and register it with `setupMiddlewares`:

```bash
npm i -D serve-index
# or pnpm add -D serve-index
# or yarn add -D serve-index
# or bun add -D serve-index
```

```js
import path from 'node:path';
import serveIndex from 'serve-index';

const publicDirectory = path.join(import.meta.dirname, 'public');
Comment thread
chenjiahan marked this conversation as resolved.

export default {
devServer: {
static: {
directory: publicDirectory,
},
setupMiddlewares: (middlewares) => {
middlewares.push({
name: 'serve-index',
// The same as `static.publicPath`
path: '/',
middleware: serveIndex(publicDirectory, { icons: true }),
Comment thread
chenjiahan marked this conversation as resolved.
});
Comment thread
chenjiahan marked this conversation as resolved.

return middlewares;
},
},
};
```

### Removed SockJS support (`ws` only)

In v2, the following SockJS options are no longer available:
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@
},
"dependencies": {
"@types/connect-history-api-fallback": "^1.5.4",
"@types/serve-index": "^1.9.4",
"@types/serve-static": "^2.2.0",
"@types/ws": "^8.18.1",
"chokidar": "^5.0.0",
"connect-history-api-fallback": "^2.0.0",
"connect-next": "^4.0.0",
"http-proxy-middleware": "^3.0.5",
"ipaddr.js": "^2.3.0",
"serve-index": "^1.9.2",
"serve-static": "^2.2.1",
"webpack-dev-middleware": "^7.4.5",
"ws": "^8.19.0"
Expand Down
124 changes: 0 additions & 124 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default defineConfig({
'webpack-dev-middleware': 'commonjs webpack-dev-middleware',
'http-proxy-middleware': 'commonjs http-proxy-middleware',
'serve-static': 'commonjs serve-static',
'serve-index': 'commonjs serve-index',
selfsigned: 'commonjs selfsigned',
},
},
Expand Down
Loading