Skip to content

Commit f5b78a1

Browse files
authored
feat!: remove serve-index dependency and related functionality (#151)
1 parent ea268c3 commit f5b78a1

File tree

10 files changed

+39
-856
lines changed

10 files changed

+39
-856
lines changed

docs/migrate-v1-to-v2.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,44 @@ npm i -D selfsigned@^5.0.0
169169
# or bun add -D selfsigned@^5.0.0
170170
```
171171
172+
### Removed `serve-index` support
173+
174+
`devServer.static.serveIndex` is removed in v2 to reduce third-party dependencies.
175+
176+
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`:
177+
178+
```bash
179+
npm i -D serve-index
180+
# or pnpm add -D serve-index
181+
# or yarn add -D serve-index
182+
# or bun add -D serve-index
183+
```
184+
185+
```js
186+
import path from 'node:path';
187+
import serveIndex from 'serve-index';
188+
189+
const publicDirectory = path.join(import.meta.dirname, 'public');
190+
191+
export default {
192+
devServer: {
193+
static: {
194+
directory: publicDirectory,
195+
},
196+
setupMiddlewares: (middlewares) => {
197+
middlewares.push({
198+
name: 'serve-index',
199+
// The same as `static.publicPath`
200+
path: '/',
201+
middleware: serveIndex(publicDirectory, { icons: true }),
202+
});
203+
204+
return middlewares;
205+
},
206+
},
207+
};
208+
```
209+
172210
### Removed SockJS support (`ws` only)
173211
174212
In v2, the following SockJS options are no longer available:

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@
4646
},
4747
"dependencies": {
4848
"@types/connect-history-api-fallback": "^1.5.4",
49-
"@types/serve-index": "^1.9.4",
5049
"@types/serve-static": "^2.2.0",
5150
"@types/ws": "^8.18.1",
5251
"chokidar": "^5.0.0",
5352
"connect-history-api-fallback": "^2.0.0",
5453
"connect-next": "^4.0.0",
5554
"http-proxy-middleware": "^3.0.5",
5655
"ipaddr.js": "^2.3.0",
57-
"serve-index": "^1.9.2",
5856
"serve-static": "^2.2.1",
5957
"webpack-dev-middleware": "^7.4.5",
6058
"ws": "^8.19.0"

pnpm-lock.yaml

Lines changed: 0 additions & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rslib.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export default defineConfig({
1313
'webpack-dev-middleware': 'commonjs webpack-dev-middleware',
1414
'http-proxy-middleware': 'commonjs http-proxy-middleware',
1515
'serve-static': 'commonjs serve-static',
16-
'serve-index': 'commonjs serve-index',
1716
selfsigned: 'commonjs selfsigned',
1817
},
1918
},

0 commit comments

Comments
 (0)