wimi/etc/webpack.common.js
0x1eef 1028613cad
Some checks failed
myip.wtf / build (push) Has been cancelled
myip.wtf / tests (push) Has been cancelled
import via preact/hooks
2024-09-12 19:47:50 -03:00

54 lines
1.3 KiB
JavaScript

const path = require("path");
const process = require("process");
const webpack = require("webpack");
const CopyPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
entry: {
index: "./src/js/index.tsx",
},
output: {
filename: "js/[name].js",
path: path.resolve(__dirname, "..", "build")
},
resolve: {
alias: {
"~": [path.resolve(__dirname, "..", "src", "js")],
"react": "preact/compat",
"react-dom": "preact/compat",
"react/jsx-runtime": "preact/jsx-runtime",
},
modules: [path.resolve(__dirname, "..", "node_modules")],
extensions: [".ts", ".tsx"]
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "esbuild-loader",
exclude: /node_modules/,
options: {
loader: "tsx",
target: "es2015"
}
},
],
},
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(),
new webpack.ProvidePlugin({
React: ["preact/compat"]
}),
],
}