wimi/webpack.common.js

52 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

const path = require("path");
const process = require("process");
2024-04-05 20:23:49 +02:00
const CopyPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
entry: {
index: "./src/js/index.tsx",
2024-04-05 20:23:49 +02:00
},
output: {
filename: "js/[name].js",
path: path.resolve(__dirname, "build")
2024-04-05 20:23:49 +02:00
},
resolve: {
2024-08-31 06:23:41 +02:00
alias: {
"~": [path.resolve("src/js/")],
"react": "preact/compat",
"react-dom": "preact/compat",
"react/jsx-runtime": "preact/jsx-runtime",
},
roots: [path.resolve("src/js"), path.resolve("node_modules")],
modules: [path.resolve("src/js"), path.resolve("node_modules")],
extensions: [".ts", ".tsx"]
2024-04-05 20:23:49 +02:00
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "esbuild-loader",
2024-04-05 20:23:49 +02:00
exclude: /node_modules/,
2024-04-26 02:59:53 +02:00
options: {
loader: "tsx",
target: "es2015"
2024-04-26 02:59:53 +02:00
}
2024-04-05 20:23:49 +02:00
},
],
},
plugins: [
new CopyPlugin({
patterns: [
{ from: "src/html/", to: "html" },
{ from: "src/css/", to: "css" },
{ from: "src/manifest.json", to: "manifest.json" },
{ from: "src/images", to: "images/" },
{ from: "src/_locales", to: "_locales/" },
{ from: "src/fonts", to: "fonts/" }
],
}),
new CleanWebpackPlugin(),
],
}