From aac38d991bd5f7eabba3ad83a13751a9efd2b549 Mon Sep 17 00:00:00 2001 From: Mqxx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:30:00 +0100 Subject: [PATCH] build config --- build.config.ts | 41 ++++++++++++++++++++++++++++++++++ deno.jsonc | 58 ++++++++++++++++++++++++++++++++++++++++--------- src/index.ts | 5 +++++ 3 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 build.config.ts diff --git a/build.config.ts b/build.config.ts new file mode 100644 index 0000000..be18a97 --- /dev/null +++ b/build.config.ts @@ -0,0 +1,41 @@ +/// +import * as esbuild from 'https://deno.land/x/esbuild@v0.19.12/mod.js'; +import { green } from 'https://deno.land/std@0.211.0/fmt/colors.ts'; +import { parseArgs } from 'https://deno.land/std@0.211.0/cli/parse_args.ts'; + +const args = parseArgs<{ + watch: boolean | undefined, + develope: boolean | undefined, + logLevel: esbuild.LogLevel +}>(Deno.args); + +const filesConfig : esbuild.BuildOptions = { + allowOverwrite: true, + logLevel: args.logLevel ?? 'info', + legalComments: args.develope ? 'inline' : 'none', + color: true, + minify: !args.develope ?? true, + outdir: './dist', + bundle: true, + format: 'esm', + sourcemap: true, + sourcesContent: true, + entryNames: '[dir]/bundle.min', + entryPoints: [ + './src/**/index.ts', + './src/**/index.scss', + ], +} + +console.log('Build process started.'); + +const timestampNow = Date.now(); + +if (args.watch) { + esbuild.context(filesConfig).then((context) => context.watch()); +} else { + esbuild.build(filesConfig).then(() => { + esbuild.stop(); + console.log(green(`esbuild ${esbuild.version} finished build in ${(Date.now() - timestampNow).toString()}ms.`)); + }) +} diff --git a/deno.jsonc b/deno.jsonc index 9188846..6ee1914 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,13 +1,51 @@ { - "tasks": { - "index": "deno run --check -A ./src/index.ts" - }, - "exclude": [ - "**/*.test.ts" - ], - "test": { - "include": [ - "**/*.test.ts" - ] + "tasks": { + "build": "deno run -A ./build.config.ts", + "build:watch": "deno run -A ./build.config.ts --watch", + "build:dev": "deno run -A ./build.config.ts --develope", + "build:dev:watch": "deno run -A ./build.config.ts --develope --watch", + "lint": "deno lint", + "test": "deno test -A --check --reload --doc --allow-none --junit-path=\"./report.xml\"" + }, + "exclude": [ + "./dist/" + ], + "test": { + "include": [ + "**/*.test.ts" + ] + }, + "compilerOptions": { + "experimentalDecorators": true, + "lib": [ + "ES6", + "DOM", + "DOM.Iterable" + ] + }, + "fmt": { + "singleQuote": true, + "lineWidth": 120 + }, + "lint": { + "rules": { + "tags": [ + "recommended" + ], + "include": [ + "camelcase", + "default-param-last", + "eqeqeq", + "explicit-function-return-type", + "explicit-module-boundary-types", + "guard-for-in", + "no-eval", + "no-sparse-arrays", + "prefer-ascii" + ], + "exclude": [ + "no-inferrable-types" + ] } + } } diff --git a/src/index.ts b/src/index.ts index e69de29..8d5f7c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -0,0 +1,5 @@ +export default { + async fetch(request : Request) { + + } +}