把 contentBase 换成 static就可以啦
devServer: { proxy: { // proxy URLs to backend development server '/api': 'http://localhost:3000' }, static: path.join(__dirname, 'public'), // boolean | string | array | object, static file location compress: true, // enable gzip compression historyApiFallback: true, // true for index.html upon 404, object for multiple paths hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin https: false, // true for self-signed, object for cert authority // ... },
webpack5 原文档 Configuration | webpack