Support Webpack

This commit is contained in:
Roj Serbest 2021-10-10 15:25:19 +03:00
parent 8b313fabb9
commit 81d9a0225e
4 changed files with 11014 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.txt
dist/
node_modules/
out/

10972
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,16 @@
{
"name": "socialvoid-deno",
"name": "my-webpack-project",
"version": "1.0.0",
"description": "Node.js, Deno & browser Socialvoid client.",
"description": "My webpack project",
"main": "dist/index.js",
"directories": {
"example": "examples"
},
"scripts": {
"build": "deno2node tsconfig.json"
"build": "webpack --mode=production --node-env=production",
"build:dev": "webpack --mode=development",
"build:prod": "webpack --mode=production --node-env=production",
"watch": "webpack --watch"
},
"repository": {
"type": "git",
@ -26,7 +29,12 @@
},
"devDependencies": {
"@types/node-fetch": "^2.5.12",
"@webpack-cli/generators": "^2.4.0",
"crypto-browserify": "^3.12.0",
"deno2node": "^1.0.0",
"typescript": "^4.4.3"
"stream-browserify": "^3.0.0",
"typescript": "^4.4.3",
"webpack": "^5.58.1",
"webpack-cli": "^4.9.0"
}
}

32
webpack.config.js Normal file
View File

@ -0,0 +1,32 @@
// Generated using webpack-cli https://github.com/webpack/webpack-cli
const path = require("path");
const isProduction = process.env.NODE_ENV == "production";
const config = {
target: "web",
entry: "./dist/mod.js",
output: {
library: "socialvoid",
filename: "socialvoid.js",
path: path.resolve(__dirname, "out"),
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
fallback: {
fs: false,
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
},
},
};
module.exports = () => {
if (isProduction) {
config.mode = "production";
} else {
config.mode = "development";
}
return config;
};