TS版本4.7以后可能会存在的问题
依赖版本
webpack配置
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWbpackPlugin = require("html-webpack-plugin");
const path = require("path");
const isPord = process.env.NODE_ENV === "production";
function resolve(dir) {
return path.resolve(__dirname, "..", dir);
}
module.exports = {
mode: isPord ? "production" : "development",
entry: {
app: "./src/main.ts",
},
output: {
path: resolve("dist"),
filename: "[name].[contenthash:8].js",
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: "ts-loader",
},
],
},
plugins: [
new HtmlWbpackPlugin({
template: "./public/index.html",
}),
new CleanWebpackPlugin({}),
],
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
devtool: isPord ? "cheap-module-source-map" : "cheap-module-eval-source-map",
devServer: {
host: "localhost",
stats: "errors-only",
port: 8081,
open: true,
},
};