style(frontend-shared): lint fixes on build.js
This commit is contained in:
parent
b313da8cec
commit
fae9bc89f1
|
@ -1,32 +1,32 @@
|
||||||
import * as esbuild from "esbuild";
|
import fs from 'node:fs';
|
||||||
import { build } from "esbuild";
|
import { fileURLToPath } from 'node:url';
|
||||||
import { globSync } from "glob";
|
import { dirname } from 'node:path';
|
||||||
import { execa } from "execa";
|
import * as esbuild from 'esbuild';
|
||||||
import fs from "node:fs";
|
import { build } from 'esbuild';
|
||||||
import { fileURLToPath } from "node:url";
|
import { globSync } from 'glob';
|
||||||
import { dirname } from "node:path";
|
import { execa } from 'execa';
|
||||||
|
|
||||||
const _filename = fileURLToPath(import.meta.url);
|
const _filename = fileURLToPath(import.meta.url);
|
||||||
const _dirname = dirname(_filename);
|
const _dirname = dirname(_filename);
|
||||||
const _package = JSON.parse(fs.readFileSync(_dirname + '/package.json', 'utf-8'));
|
const _package = JSON.parse(fs.readFileSync(_dirname + '/package.json', 'utf-8'));
|
||||||
|
|
||||||
const entryPoints = globSync("./src/**/**.{ts,tsx}");
|
const entryPoints = globSync('./src/**/**.{ts,tsx}');
|
||||||
|
|
||||||
/** @type {import('esbuild').BuildOptions} */
|
/** @type {import('esbuild').BuildOptions} */
|
||||||
const options = {
|
const options = {
|
||||||
entryPoints,
|
entryPoints,
|
||||||
minify: process.env.NODE_ENV === 'production',
|
minify: process.env.NODE_ENV === 'production',
|
||||||
outdir: "./js-built",
|
outdir: './js-built',
|
||||||
target: "es2022",
|
target: 'es2022',
|
||||||
platform: "browser",
|
platform: 'browser',
|
||||||
format: "esm",
|
format: 'esm',
|
||||||
sourcemap: 'linked',
|
sourcemap: 'linked',
|
||||||
};
|
};
|
||||||
|
|
||||||
// js-built配下をすべて削除する
|
// js-built配下をすべて削除する
|
||||||
fs.rmSync('./js-built', { recursive: true, force: true });
|
fs.rmSync('./js-built', { recursive: true, force: true });
|
||||||
|
|
||||||
if (process.argv.map(arg => arg.toLowerCase()).includes("--watch")) {
|
if (process.argv.map(arg => arg.toLowerCase()).includes('--watch')) {
|
||||||
await watchSrc();
|
await watchSrc();
|
||||||
} else {
|
} else {
|
||||||
await buildSrc();
|
await buildSrc();
|
||||||
|
@ -36,7 +36,7 @@ async function buildSrc() {
|
||||||
console.log(`[${_package.name}] start building...`);
|
console.log(`[${_package.name}] start building...`);
|
||||||
|
|
||||||
await build(options)
|
await build(options)
|
||||||
.then(it => {
|
.then(() => {
|
||||||
console.log(`[${_package.name}] build succeeded.`);
|
console.log(`[${_package.name}] build succeeded.`);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -65,7 +65,7 @@ function buildDts() {
|
||||||
{
|
{
|
||||||
stdout: process.stdout,
|
stdout: process.stdout,
|
||||||
stderr: process.stderr,
|
stderr: process.stderr,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ async function watchSrc() {
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
|
||||||
console.log(`[${_package.name}] start watching...`)
|
console.log(`[${_package.name}] start watching...`);
|
||||||
|
|
||||||
const context = await esbuild.context({ ...options, plugins });
|
const context = await esbuild.context({ ...options, plugins });
|
||||||
await context.watch();
|
await context.watch();
|
||||||
|
|
Loading…
Reference in a new issue