@konomi-app/k2 0.2.0 → 0.2.1

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.
@@ -1,8 +1,8 @@
1
1
  import { program } from 'commander';
2
2
  import { build } from 'vite';
3
- import { importPluginConfig } from '../lib/import.js';
4
3
  import { getViteConfig } from '../lib/vite.js';
5
4
  import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
5
+ import path from 'path';
6
6
  export default function command() {
7
7
  program
8
8
  .command('build')
@@ -12,8 +12,21 @@ export default function command() {
12
12
  export async function action() {
13
13
  console.group('🍳 Build the project for production');
14
14
  try {
15
- const config = await importPluginConfig();
16
- const viteConfig = getViteConfig(config);
15
+ const viteConfig = getViteConfig({
16
+ build: {
17
+ rollupOptions: {
18
+ input: {
19
+ config: path.join('src', 'config', 'index.ts'),
20
+ desktop: path.join('src', 'desktop', 'index.ts'),
21
+ },
22
+ output: {
23
+ entryFileNames: '[name].js',
24
+ chunkFileNames: '[name].js',
25
+ assetFileNames: '[name].[ext]',
26
+ },
27
+ },
28
+ },
29
+ });
17
30
  await build({
18
31
  ...viteConfig,
19
32
  mode: 'production',
@@ -3,7 +3,10 @@ import { createServer, build } from 'vite';
3
3
  import { importPluginConfig } from '../lib/import.js';
4
4
  import { getViteConfig } from '../lib/vite.js';
5
5
  import chokidar from 'chokidar';
6
- import { PLUGIN_DEVELOPMENT_DIRECTORY } from '../lib/constants.js';
6
+ import { PLUGIN_DEVELOPMENT_DIRECTORY, PLUGIN_WORKSPACE_DIRECTORY } from '../lib/constants.js';
7
+ import path from 'path';
8
+ import { DEFAULT_PORT } from '../lib/constants.js';
9
+ import fs from 'fs-extra';
7
10
  export default function command() {
8
11
  program.command('dev').description('Start development server.').action(action);
9
12
  }
@@ -15,7 +18,28 @@ export async function action() {
15
18
  ignored: /node_modules/,
16
19
  persistent: true,
17
20
  });
18
- const viteConfig = getViteConfig(config);
21
+ const viteConfig = getViteConfig({
22
+ build: {
23
+ rollupOptions: {
24
+ input: {
25
+ config: path.join('src', 'config', 'index.ts'),
26
+ desktop: path.join('src', 'desktop', 'index.ts'),
27
+ },
28
+ output: {
29
+ entryFileNames: '[name].js',
30
+ chunkFileNames: '[name].js',
31
+ assetFileNames: '[name].[ext]',
32
+ },
33
+ },
34
+ },
35
+ server: {
36
+ port: config.server?.port ?? DEFAULT_PORT,
37
+ https: {
38
+ key: fs.readFileSync(path.join(PLUGIN_WORKSPACE_DIRECTORY, 'localhost-key.pem')),
39
+ cert: fs.readFileSync(path.join(PLUGIN_WORKSPACE_DIRECTORY, 'localhost-cert.pem')),
40
+ },
41
+ },
42
+ });
19
43
  const listener = async () => build({
20
44
  ...viteConfig,
21
45
  mode: 'development',
package/dist/lib/vite.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import path from 'path';
2
- import fs from 'fs-extra';
3
- import { DEFAULT_PORT, PLUGIN_DEVELOPMENT_DIRECTORY, PLUGIN_WORKSPACE_DIRECTORY, } from './constants.js';
2
+ import { PLUGIN_DEVELOPMENT_DIRECTORY } from './constants.js';
4
3
  import tsconfigPaths from 'vite-tsconfig-paths';
5
4
  export const getViteConfig = (config) => {
6
5
  return {
@@ -9,15 +8,7 @@ export const getViteConfig = (config) => {
9
8
  outDir: PLUGIN_DEVELOPMENT_DIRECTORY,
10
9
  emptyOutDir: true,
11
10
  rollupOptions: {
12
- input: {
13
- config: path.join('src', 'config', 'index.ts'),
14
- desktop: path.join('src', 'desktop', 'index.ts'),
15
- },
16
- output: {
17
- entryFileNames: '[name].js',
18
- chunkFileNames: '[name].js',
19
- assetFileNames: '[name].[ext]',
20
- },
11
+ ...config.build?.rollupOptions,
21
12
  onwarn: (warning, warn) => {
22
13
  if (['MODULE_LEVEL_DIRECTIVE'].includes(warning.code ?? '')) {
23
14
  return;
@@ -27,13 +18,7 @@ export const getViteConfig = (config) => {
27
18
  },
28
19
  },
29
20
  plugins: [tsconfigPaths()],
30
- server: {
31
- port: config.server?.port ?? DEFAULT_PORT,
32
- https: {
33
- key: fs.readFileSync(path.join(PLUGIN_WORKSPACE_DIRECTORY, 'localhost-key.pem')),
34
- cert: fs.readFileSync(path.join(PLUGIN_WORKSPACE_DIRECTORY, 'localhost-cert.pem')),
35
- },
36
- },
21
+ server: config.server,
37
22
  resolve: {
38
23
  alias: { '@': path.resolve('src') },
39
24
  },
@@ -22,7 +22,7 @@ export const buildWithWebpack = async (props) => {
22
22
  plugins: [new TsconfigPathsPlugin({ configFile: path.join(cwd(), 'tsconfig.json') })],
23
23
  },
24
24
  cache: { type: 'filesystem' },
25
- output: { filename: '[name].js', path: outDir },
25
+ output: { filename: '[name].js', path: path.resolve(outDir) },
26
26
  module: {
27
27
  rules: [
28
28
  { test: /\.tsx?$/, exclude, loader: 'ts-loader' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/k2",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "kintone sdk",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",