This repository has been archived on 2023-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
old-monorepo/Dashboard/webpack.config.js

82 lines
2 KiB
JavaScript
Raw Normal View History

const path = require("path");
const fs = require("fs");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
module.exports = (env, argv) => {
const nodeModules = {};
fs.readdirSync("node_modules")
.filter((x) => [".bin"].indexOf(x) === -1)
.forEach((mod) => {
nodeModules[mod] = `commonjs ${mod}`;
});
return {
entry: "./src/index.tsx",
output: {
path: path.join(__dirname, "build"),
filename: "index.bundle.js",
},
mode: process.env.NODE_ENV || "development",
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
devServer: { contentBase: path.join(__dirname, "src") },
devtool: "source-map",
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
},
},
},
{
test: /\.(css|scss)$/,
use: ["style-loader", "css-loader"],
},
{
2021-07-09 12:31:16 +02:00
test: /\.(png|jp(e*)g|svg|gif)$/,
use: [
{
loader: "file-loader",
options: {
name: "assets/[hash]-[name].[ext]",
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "index.html"),
}),
new ForkTsCheckerWebpackPlugin(),
{
apply: (compiler) => {
compiler.hooks.done.tap("DonePlugin", () => {
if (argv.mode === "production") {
setTimeout(() => {
process.exit(0);
});
}
});
},
},
],
watch: true,
target: "electron-renderer",
externals: nodeModules,
};
};