Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const path = require('path');
const execSync = require('child_process').execSync;
const { globPlugin } = require('esbuild-plugin-glob');

execSync('npx rimraf ./dist && mkdir dist');

const copy = ['json', 'html', 'png'];

const alias = {
name: 'alias',
setup(build) {
build.onResolve({ filter: /^@\/.*/ }, (args) => {
console.log('Entered onResolve');
return {
path: path.resolve(__dirname, './src', args.path.replace(/^@\//, ''))
};
});
}
};

require('esbuild')
.build({
entryPoints: [`./src/**/*.{js,${copy.join(',')}}`],
bundle: false,
outdir: './dist',
outbase: './src',
platform: 'node',
target: 'node16.0',
format: 'cjs',
minify: false,
sourcemap: true,
keepNames: true,
loader: copy.reduce((acc, ext) => ({ ...acc, [`.${ext}`]: 'copy' }), {}),
plugins: [alias, globPlugin()]
})
.catch(() => process.exit(1));
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"description": "Backend",
"main": "src/app.js",
"scripts": {
"build": "npm run clean && npm run build-babel && npm run copy",
"build-babel": "babel -d ./dist ./src -s",
"clean": "rm -rf dist && mkdir dist",
"copy": "babel src --out-dir ./dist --copy-files",
"build": "node esbuild.config.js",
"dev": "nodemon --exec babel-node src/app.js",
"format": "prettier --write --cache \"**/*.{js,md}\"",
"lint": "eslint src --ext js,md --ignore-path .gitignore --fix --cache --report-unused-disable-directives",
Expand Down Expand Up @@ -59,10 +56,14 @@
"@trivago/prettier-plugin-sort-imports": "4.1.1",
"babel-plugin-module-resolver": "5.0.0",
"dotenv": "16.0.1",
"esbuild": "0.18.17",
"esbuild-plugin-alias-path": "2.0.2",
"esbuild-plugin-glob": "2.2.2",
"eslint": "8.45.0",
"eslint-plugin-import": "2.27.5",
"lefthook": "1.4.3",
"nodemon": "3.0.1",
"prettier": "2.8.8"
"prettier": "2.8.8",
"rimraf": "5.0.1"
}
}
Loading