hyperchat/packages/electron/webpack.config.mjs

78 lines
2.3 KiB
JavaScript

// import path from "path";
// import webpack from "webpack";
// import nodeExternals from "webpack-node-externals";
// import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
// import { fileURLToPath } from "url";
// const __dirname = path.dirname(fileURLToPath(import.meta.url));
// export default (env, argv) => {
// console.log("ENV:", process.env.NODE_ENV); // 打印出传入的环境变量
// const isDev = process.env.NODE_ENV !== "production" ? true : false;
// return {
// target: "electron-main",
// entry: {
// main: "./src/main.mts",
// preload: "./src/preload.mts",
// },
// externalsPresets: { node: true }, // in order to ignore built-in modules like path, fs, etc.
// externals: [nodeExternals()],
// plugins: [
// new webpack.EnvironmentPlugin({
// NODE_ENV: "production",
// myEnv: process.env.myEnv || "prod",
// runtime: "electron",
// use_electron: "1",
// }),
// ],
// module: {
// rules: [
// {
// test: /\.[cm]?(ts|js)x?$/,
// use: {
// loader: "ts-loader",
// options: {
// configFile: "tsconfig.json",
// },
// },
// exclude: /node_modules/,
// resolve: {
// fullySpecified: false,
// },
// },
// {
// test: /\.txt$/i,
// use: "raw-loader",
// },
// ],
// },
// resolve: {
// extensions: [".tsx", ".ts", ".js", ".mts", ".mjs", ".jsx", ".css"],
// extensionAlias: {
// ".js": [".js", ".ts"],
// ".cjs": [".cjs", ".cts"],
// ".mjs": [".mjs", ".mts"],
// },
// alias: {
// "@dadigua/hyperchat-shared": path.resolve(__dirname, "../shared/dist"),
// },
// plugins: [
// new TsconfigPathsPlugin({
// configFile: path.resolve(__dirname, "./tsconfig.json"),
// }),
// ],
// },
// output: {
// filename: "[name].js",
// chunkFilename: "[name].js",
// path: path.resolve(__dirname, "dist"),
// libraryTarget: "commonjs2",
// },
// mode: isDev ? "development" : "production",
// devtool: isDev ? "source-map" : false,
// optimization: {
// minimize: !isDev,
// },
// };
// };