more optimization

This commit is contained in:
2023-05-17 23:02:43 +01:00
parent 1d45225336
commit dce003d7f0
8 changed files with 96 additions and 63 deletions

View File

@ -1,19 +1,23 @@
const fs = require("fs")
const isProduction = process.env.NODE_ENV == "production";
const entry = {
lib: "./src/index.ts",
}
for (const file of fs.readdirSync("./test/")) {
if (/.ts$/.test(file)) {
const name = file.replace(/.ts$/, "")
entry[`test/${name}`] = `./test/${file}`
if (!isProduction) {
for (const file of fs.readdirSync("./test/")) {
if (/.ts$/.test(file)) {
const name = file.replace(/.ts$/, "")
entry[`test/${name}`] = `./test/${file}`
}
}
}
module.exports = {
mode: process.env.NODE_ENV || "development",
devtool: "inline-source-map",
target: "browserslist",
devtool: isProduction ? "source-map" : "eval",
entry,
resolve: {
extensions: [".ts", ".js"],
@ -27,9 +31,13 @@ module.exports = {
output: {
filename: "[name].js",
path: `${__dirname}/dist`,
clean: true,
library: {
type: "umd",
name: "Nostr",
},
},
optimization: {
usedExports: true,
},
}