remove webpack, use esbuild instead.

this probably breaks docker. @cameri help.
This commit is contained in:
fiatjaf
2022-02-12 14:28:48 -03:00
parent 022525aa26
commit 270f242d1f
7 changed files with 40 additions and 39 deletions

3
.gitignore vendored
View File

@@ -1,5 +1,4 @@
yarn.lock
node_modules
*.wasm
out.js
dist
public/main.js

View File

@@ -2,13 +2,13 @@ FROM node:14-alpine as build
WORKDIR /app
COPY index.html main.js package.json webpack.config.js /app/
COPY index.html main.js package.json build.js /app/
RUN yarn \
&& npm run build
&& yarn run build
FROM nginx:stable-alpine as nginx-nostr-relay-registry
COPY ./nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /app
COPY --from=build /app/public /app

26
build.js Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env node
const esbuild = require('esbuild')
const alias = require('esbuild-plugin-alias')
const nodeGlobals = require('@esbuild-plugins/node-globals-polyfill').default
const prod = process.argv.indexOf('prod') !== -1
esbuild
.build({
bundle: true,
entryPoints: ['main.js'],
outdir: 'public',
plugins: [
alias({
stream: require.resolve('readable-stream')
}),
nodeGlobals({buffer: true})
],
sourcemap: prod ? false : 'inline',
define: {
window: 'self',
global: 'self'
}
})
.then(() => console.log('build success.'))

View File

@@ -1,10 +1,6 @@
server {
listen 80;
root /app;
include mime.types;
types {
application/wasm wasm;
}
root /app/public;
location / {
index index.html;

View File

@@ -1,15 +1,17 @@
{
"dependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"buffer": "^6.0.3",
"nostr-tools": "^0.12.4",
"esbuild": "^0.14.21",
"esbuild-plugin-alias": "^0.2.1",
"events": "^3.3.0",
"nostr-tools": "^0.22.1",
"readable-stream": "^3.6.0",
"vue": "3"
},
"devDependencies": {
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
},
"devDependencies": {},
"scripts": {
"build": "mkdir -p dist/ && cp index.html dist/ && webpack"
"build": "./build.js prod",
"watch": "ag -l --js | entr ./build.js"
}
}

View File

@@ -5,4 +5,4 @@
<div id="app" style="font-family: monospace"></div>
<script src="out.js"></script>
<script src="main.js"></script>

View File

@@ -1,22 +0,0 @@
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode: 'development',
entry: './main.js',
output: {
path: `${__dirname}/dist`,
filename: 'out.js'
},
experiments: {asyncWebAssembly: true},
resolve: {
alias: {
stream: 'readable-stream'
},
fallback: {
buffer: 'buffer/index.js',
stream: 'readable-stream/readable.js',
crypto: false
}
}
}