【发布时间】:2022-01-09 16:28:45
【问题描述】:
我无法使用 webpack 开发服务器来处理我当前的配置。我不断收到 404,没有任何错误或提示,为什么或是什么导致了错误。 我的项目源码目录结构
.src
├── client
│ ├── client.ts
│ ├── index.html
│ └── tsconfig.json
└── server
├── server.ts
└── tsconfig.json
我的 webpack.config.js
const path = require("path");
const copyPlugin = require("copy-webpack-plugin");
module.exports = {
entry: "./src/client/client.ts",
mode: "development",
devServer: {
watchFiles: ["src/**/*"],
//port: 3000,
hot: true,
compress: true,
open: "Chrome",
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.css$/i,
include: path.resolve(__dirname, "src"),
use: ["style-loader", "css-loader", "postcss-loader"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
plugins: [
new copyPlugin({
patterns: [{ from: "./src/client/index.html", to: "/client/index.html" }],
}),
],
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "./dist"),
publicPath: "/",
clean: true,
},
};
我使用"start": "webpack serve --mode=development --open", 作为我的启动脚本。
谢谢
【问题讨论】:
标签: webpack webpack-dev-server