@konomi-app/k2 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,18 +3,23 @@ import fs from 'fs-extra';
3
3
  import path from 'path';
4
4
  import { WORKSPACE_DIRECTORY } from '../lib/constants.js';
5
5
  import { buildWithEsbuild } from '../lib/esbuild.js';
6
+ import { importK2Config } from '../lib/import.js';
7
+ import { getDefaultK2Config } from '../lib/k2.js';
8
+ import { buildTailwind } from './build-tailwind.js';
6
9
  export default function command() {
7
10
  program
8
11
  .command('esbuild-build')
9
12
  .option('-o, --outdir <outdir>', 'Output directory.', path.join(WORKSPACE_DIRECTORY, 'prod'))
10
13
  .option('-i, --input <input>', 'Input directory.', path.join('src', 'apps'))
14
+ .option('--config <config>', 'k2 config file path')
11
15
  .description("Build the project for production. (It's a wrapper of webpack build command.)")
12
16
  .action(action);
13
17
  }
14
18
  export async function action(options) {
15
19
  console.group('🍳 Build the project for production');
16
20
  try {
17
- const { outdir, input } = options;
21
+ const { outdir, input, config } = options;
22
+ const outDir = path.resolve(outdir);
18
23
  const allProjects = fs.readdirSync(path.resolve(input));
19
24
  const entryPoints = allProjects.reduce((acc, dir) => {
20
25
  for (const filename of ['index.ts', 'index.js', 'index.mjs']) {
@@ -25,13 +30,18 @@ export async function action(options) {
25
30
  return acc;
26
31
  }, {});
27
32
  console.log(`📁 ${Object.keys(entryPoints).length} entry points`);
28
- await buildWithEsbuild({
29
- entryPoints,
30
- outdir,
31
- sourcemap: false,
32
- minify: true,
33
- target: 'es2020',
34
- });
33
+ const k2Config = config ? await importK2Config(config) : getDefaultK2Config();
34
+ const fullConfig = { ...k2Config, outDir };
35
+ await Promise.allSettled([
36
+ buildWithEsbuild({
37
+ entryPoints,
38
+ outdir,
39
+ sourcemap: false,
40
+ minify: true,
41
+ target: 'es2020',
42
+ }),
43
+ buildTailwind(fullConfig),
44
+ ]);
35
45
  console.log('✨ Build success.');
36
46
  }
37
47
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/k2",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "kintone sdk",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",