@konomi-app/k2 1.0.3 → 1.2.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.
|
@@ -24,7 +24,14 @@ export async function action(options) {
|
|
|
24
24
|
}
|
|
25
25
|
return acc;
|
|
26
26
|
}, {});
|
|
27
|
-
|
|
27
|
+
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
|
+
});
|
|
28
35
|
console.log('✨ Build success.');
|
|
29
36
|
}
|
|
30
37
|
catch (error) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { esmImport } from '../lib/import.js';
|
|
3
|
+
import { outputCss } from '../lib/tailwind.js';
|
|
4
|
+
export const buildTailwind = async (config) => {
|
|
5
|
+
if (!config.tailwind?.css || !config.tailwind?.config) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const tailwindConfig = (await esmImport(path.resolve(config.tailwind.config))).default;
|
|
9
|
+
const inputPath = path.resolve(config.tailwind.css);
|
|
10
|
+
await outputCss({
|
|
11
|
+
inputPath,
|
|
12
|
+
outputPath: path.join(config.outDir, 'tailwind.css'),
|
|
13
|
+
config: tailwindConfig,
|
|
14
|
+
minify: true,
|
|
15
|
+
});
|
|
16
|
+
console.log('✨ Built tailwind.css');
|
|
17
|
+
};
|
package/dist/commands/build.js
CHANGED
|
@@ -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 base from './build-base.js';
|
|
6
|
+
import { buildTailwind } from './build-tailwind.js';
|
|
7
|
+
import { importK2Config } from '../lib/import.js';
|
|
8
|
+
import { getDefaultK2Config } from '../lib/k2.js';
|
|
6
9
|
export default function command() {
|
|
7
10
|
program
|
|
8
11
|
.command('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 entries = allProjects.reduce((acc, dir) => {
|
|
20
25
|
for (const filename of ['index.ts', 'index.js', 'index.mjs']) {
|
|
@@ -24,7 +29,9 @@ export async function action(options) {
|
|
|
24
29
|
}
|
|
25
30
|
return acc;
|
|
26
31
|
}, {});
|
|
27
|
-
await
|
|
32
|
+
const k2Config = config ? await importK2Config(config) : getDefaultK2Config();
|
|
33
|
+
const fullConfig = { ...k2Config, outDir };
|
|
34
|
+
await Promise.allSettled([base({ entries, outDir }), buildTailwind(fullConfig)]);
|
|
28
35
|
console.log('✨ Build success.');
|
|
29
36
|
}
|
|
30
37
|
catch (error) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { getTailwindConfigFromK2Config, watchTailwindCSS } from '../../lib/tailwind.js';
|
|
4
|
+
import fs from 'fs-extra';
|
|
4
5
|
export const watchCss = async (params) => {
|
|
5
6
|
const { k2Config, outdir } = params;
|
|
6
7
|
if (!k2Config.tailwind?.css || !k2Config.tailwind?.config) {
|
|
@@ -9,6 +10,10 @@ export const watchCss = async (params) => {
|
|
|
9
10
|
}
|
|
10
11
|
const tailwindConfig = await getTailwindConfigFromK2Config(k2Config.tailwind);
|
|
11
12
|
const input = path.resolve(k2Config.tailwind.css);
|
|
13
|
+
const output = path.join(outdir, 'tailwind.css');
|
|
14
|
+
if (!(await fs.pathExists(output))) {
|
|
15
|
+
await fs.outputFile(output, '');
|
|
16
|
+
}
|
|
12
17
|
return watchTailwindCSS({
|
|
13
18
|
input,
|
|
14
19
|
output: path.join(outdir, 'tailwind.css'),
|
package/dist/lib/k2.js
ADDED
package/package.json
CHANGED