代码拉取完成,页面将自动刷新
import HtmlWebpackPlugin from "html-webpack-plugin";
import * as path from "path";
import { Configuration as WebpackConfiguration } from "webpack";
import { Configuration as WebpackDevServerConfiguration } from "webpack-dev-server";
const rootPath = path.resolve(__dirname, ".");
interface Configuration extends WebpackConfiguration {
devServer?: WebpackDevServerConfiguration;
}
const config: Configuration = {
resolve: {
extensions: [".tsx", ".ts", ".js"],
mainFields: ["main", "module", "browser"],
alias: {
'@': path.resolve(__dirname, './src/renderer')
}
},
entry: path.resolve(rootPath, "src/renderer", "index.tsx"),
target: "electron-renderer",
devtool: "source-map",
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
include: /src/,
use: {
loader: "ts-loader",
},
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'less-loader' }
]
}
],
},
devServer: {
static: {
directory: path.resolve(rootPath, "dist/renderer"),
publicPath: "/",
},
port: 5000,
historyApiFallback: true,
compress: true,
},
output: {
path: path.resolve(rootPath, "dist/renderer"),
filename: "js/[name].js",
},
plugins: [
new HtmlWebpackPlugin({ template: path.resolve(rootPath, "index.html") }),
],
};
export default config;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。