Skip to content

Commit

Permalink
build config
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx committed Mar 5, 2024
1 parent fa040be commit aac38d9
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 10 deletions.
41 changes: 41 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/// <reference lib="deno.ns" />
import * as esbuild from 'https://deno.land/x/[email protected]/mod.js';
import { green } from 'https://deno.land/[email protected]/fmt/colors.ts';
import { parseArgs } from 'https://deno.land/[email protected]/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.`));
})
}
58 changes: 48 additions & 10 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
async fetch(request : Request) {

}
}

0 comments on commit aac38d9

Please sign in to comment.