@okam/directus-block 1.2.0 → 1.2.2
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.
- package/blocks/BlockWysiwyg/config.d.ts +4 -0
- package/blocks/BlockWysiwyg/index.d.ts +4 -0
- package/blocks/BlockWysiwyg/interface.d.ts +17 -0
- package/components/BlockDispatcher/config.d.ts +3 -0
- package/components/BlockDispatcher/interface.d.ts +16 -0
- package/components/BlockSerializer/interface.d.ts +31 -0
- package/generated/fragment-masking.d.ts +15 -0
- package/generated/graphql.d.ts +64 -0
- package/index.d.ts +6 -0
- package/index.js +96 -0
- package/index.mjs +5966 -0
- package/package.json +1 -1
- package/style.css +1 -0
- package/types/block.d.ts +27 -0
- package/utils/get-block-props.d.ts +17 -0
- package/utils/index.d.ts +4 -0
- package/utils/merge-configs.d.ts +9 -0
- package/.eslintrc.js +0 -21
- package/.storybook/.eslintrc.js +0 -29
- package/.storybook/main.ts +0 -33
- package/.storybook/preview.ts +0 -0
- package/.storybook/tsconfig.json +0 -17
- package/CHANGELOG.md +0 -21
- package/README.md +0 -161
- package/project.json +0 -57
- package/src/blocks/BlockWysiwyg/config.tsx +0 -10
- package/src/blocks/BlockWysiwyg/index.tsx +0 -38
- package/src/blocks/BlockWysiwyg/interface.ts +0 -13
- package/src/components/BlockDispatcher/config.ts +0 -10
- package/src/components/BlockDispatcher/index.tsx +0 -30
- package/src/components/BlockDispatcher/interface.ts +0 -17
- package/src/components/BlockSerializer/index.tsx +0 -40
- package/src/components/BlockSerializer/interface.ts +0 -51
- package/src/generated/fragment-masking.ts +0 -66
- package/src/generated/graphql.ts +0 -31
- package/src/index.ts +0 -30
- package/src/types/block.ts +0 -40
- package/src/utils/get-block-props.ts +0 -44
- package/src/utils/index.ts +0 -5
- package/src/utils/merge-configs.ts +0 -21
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -25
- package/vite.config.ts +0 -51
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { type TypedDocumentNode } from '@graphql-typed-document-node/core'
|
|
2
|
-
import type { Nullable, TDefaultComponent } from '@okam/stack-ui'
|
|
3
|
-
import type { Variables } from 'graphql-request'
|
|
4
|
-
import type { FunctionComponent } from 'react'
|
|
5
|
-
import type {
|
|
6
|
-
TCommonBlockFragment,
|
|
7
|
-
TAdditionalProps,
|
|
8
|
-
TBlockQuery,
|
|
9
|
-
TBlockVariables,
|
|
10
|
-
TBlockDocument,
|
|
11
|
-
} from '../../types/block'
|
|
12
|
-
|
|
13
|
-
export interface TBlock<
|
|
14
|
-
BlockFragment extends TCommonBlockFragment = TCommonBlockFragment,
|
|
15
|
-
BlockVariables extends Variables = Variables,
|
|
16
|
-
> {
|
|
17
|
-
collection?: Nullable<string>
|
|
18
|
-
item?: Nullable<BlockFragment>
|
|
19
|
-
variables?: TBlockVariables<BlockVariables>
|
|
20
|
-
document?: TypedDocumentNode<TBlockQuery<BlockFragment>, BlockVariables>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type TBlockSerializerProps<
|
|
24
|
-
BlockFragment extends TCommonBlockFragment = TCommonBlockFragment,
|
|
25
|
-
BlockVariables extends Variables = TBlockVariables,
|
|
26
|
-
AdditionalProps extends TAdditionalProps = TAdditionalProps,
|
|
27
|
-
> = TBlock<BlockFragment, BlockVariables> &
|
|
28
|
-
TDefaultComponent & {
|
|
29
|
-
config?: TBlockSerializerConfig
|
|
30
|
-
defaultVariant?: string
|
|
31
|
-
additionalProps?: AdditionalProps
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type TBlockFunctionComponent<BlockFragment extends TCommonBlockFragment = TCommonBlockFragment> =
|
|
35
|
-
FunctionComponent<TBlockSerializerProps<BlockFragment>>
|
|
36
|
-
|
|
37
|
-
export type TBlockSerializerConfigComponent<BlockFragment extends TCommonBlockFragment = TCommonBlockFragment> = {
|
|
38
|
-
[blockKey: string]: {
|
|
39
|
-
default: TBlockFunctionComponent<BlockFragment>
|
|
40
|
-
document?: TBlockDocument<BlockFragment>
|
|
41
|
-
defaultVariant?: string
|
|
42
|
-
getVariant?: (props: TBlockSerializerProps<BlockFragment>) => Nullable<string>
|
|
43
|
-
variants?: {
|
|
44
|
-
[blockVariant: string]: TBlockFunctionComponent<BlockFragment>
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface TBlockSerializerConfig {
|
|
50
|
-
components: TBlockSerializerConfigComponent
|
|
51
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
-
import { FragmentDefinitionNode } from 'graphql'
|
|
4
|
-
import { Incremental } from './graphql';
|
|
5
|
-
|
|
6
|
-
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
|
|
7
|
-
infer TType,
|
|
8
|
-
any
|
|
9
|
-
>
|
|
10
|
-
? [TType] extends [{ ' $fragmentName'?: infer TKey }]
|
|
11
|
-
? TKey extends string
|
|
12
|
-
? { ' $fragmentRefs'?: { [key in TKey]: TType } }
|
|
13
|
-
: never
|
|
14
|
-
: never
|
|
15
|
-
: never;
|
|
16
|
-
|
|
17
|
-
// return non-nullable if `fragmentType` is non-nullable
|
|
18
|
-
export function useFragment<TType>(
|
|
19
|
-
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
20
|
-
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
|
|
21
|
-
): TType;
|
|
22
|
-
// return nullable if `fragmentType` is nullable
|
|
23
|
-
export function useFragment<TType>(
|
|
24
|
-
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
25
|
-
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
|
|
26
|
-
): TType | null | undefined;
|
|
27
|
-
// return array of non-nullable if `fragmentType` is array of non-nullable
|
|
28
|
-
export function useFragment<TType>(
|
|
29
|
-
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
30
|
-
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
|
|
31
|
-
): ReadonlyArray<TType>;
|
|
32
|
-
// return array of nullable if `fragmentType` is array of nullable
|
|
33
|
-
export function useFragment<TType>(
|
|
34
|
-
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
35
|
-
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
|
|
36
|
-
): ReadonlyArray<TType> | null | undefined;
|
|
37
|
-
export function useFragment<TType>(
|
|
38
|
-
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
39
|
-
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
|
|
40
|
-
): TType | ReadonlyArray<TType> | null | undefined {
|
|
41
|
-
return fragmentType as any;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function makeFragmentData<
|
|
45
|
-
F extends DocumentTypeDecoration<any, any>,
|
|
46
|
-
FT extends ResultOf<F>
|
|
47
|
-
>(data: FT, _fragment: F): FragmentType<F> {
|
|
48
|
-
return data as FragmentType<F>;
|
|
49
|
-
}
|
|
50
|
-
export function isFragmentReady<TQuery, TFrag>(
|
|
51
|
-
queryNode: DocumentTypeDecoration<TQuery, any>,
|
|
52
|
-
fragmentNode: TypedDocumentNode<TFrag>,
|
|
53
|
-
data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
|
|
54
|
-
): data is FragmentType<typeof fragmentNode> {
|
|
55
|
-
const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
|
|
56
|
-
?.deferredFields;
|
|
57
|
-
|
|
58
|
-
if (!deferredFields) return true;
|
|
59
|
-
|
|
60
|
-
const fragDef = (fragmentNode as any).definitions[0] as FragmentDefinitionNode | undefined;
|
|
61
|
-
const fragName = fragDef?.name?.value;
|
|
62
|
-
|
|
63
|
-
const fields = (fragName && deferredFields[fragName]) || [];
|
|
64
|
-
//@ts-ignore
|
|
65
|
-
return fields.length > 0 && fields.every((field) => data && field in data);
|
|
66
|
-
}
|
package/src/generated/graphql.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* eslint-disable prettier/prettier */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
4
|
-
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
|
|
5
|
-
|
|
6
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
7
|
-
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }
|
|
8
|
-
|
|
9
|
-
export type Scalars = {
|
|
10
|
-
ID: { input: string; output: string; }
|
|
11
|
-
String: { input: string; output: string; }
|
|
12
|
-
Boolean: { input: boolean; output: boolean; }
|
|
13
|
-
Int: { input: number; output: number; }
|
|
14
|
-
Float: { input: number; output: number; }
|
|
15
|
-
/** ISO8601 Date values */
|
|
16
|
-
Date: { input: any; output: any; }
|
|
17
|
-
/** BigInt value */
|
|
18
|
-
GraphQLBigInt: { input: any; output: any; }
|
|
19
|
-
/** A Float or a String */
|
|
20
|
-
GraphQLStringOrFloat: { input: any; output: any; }
|
|
21
|
-
/** Hashed string values */
|
|
22
|
-
Hash: { input: any; output: any; }
|
|
23
|
-
/** The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
|
|
24
|
-
JSON: { input: any; output: any; }
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type BlockSettingsFragment = { __typename?: 'block_settings'; tokens?: any | null; variant?: string | null } & {
|
|
28
|
-
' $fragmentName'?: 'BlockSettingsFragment'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const BlockSettingsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BlockSettings"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"block_settings"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"tokens"}},{"kind":"Field","name":{"kind":"Name","value":"variant"}}]}}]} as unknown as DocumentNode<BlockSettingsFragment, unknown>;
|
package/src/index.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Components
|
|
2
|
-
export { default as BlockDispatcher } from './components/BlockDispatcher'
|
|
3
|
-
export { default as BlockSerializer } from './components/BlockSerializer'
|
|
4
|
-
|
|
5
|
-
// Types
|
|
6
|
-
export type { TBlockDispatcherProps } from './components/BlockDispatcher/interface'
|
|
7
|
-
export type {
|
|
8
|
-
TBlockSerializerConfig,
|
|
9
|
-
TBlockSerializerProps,
|
|
10
|
-
TBlock,
|
|
11
|
-
TBlockSerializerConfigComponent,
|
|
12
|
-
} from './components/BlockSerializer/interface'
|
|
13
|
-
export type {
|
|
14
|
-
TAdditionalProps,
|
|
15
|
-
TCommonBlockFragment,
|
|
16
|
-
TBlockQuery,
|
|
17
|
-
TBlockDocument,
|
|
18
|
-
TBlockVariables,
|
|
19
|
-
} from './types/block'
|
|
20
|
-
|
|
21
|
-
// Blocks
|
|
22
|
-
export { default as BlockWysiwyg } from './blocks/BlockWysiwyg'
|
|
23
|
-
|
|
24
|
-
// Utils
|
|
25
|
-
export { default as getBlockProps } from './utils/get-block-props'
|
|
26
|
-
export { default as mergeConfigs } from './utils/merge-configs'
|
|
27
|
-
|
|
28
|
-
// Configs
|
|
29
|
-
export { default as blockWysiwygConfig } from './blocks/BlockWysiwyg/config'
|
|
30
|
-
export { default as baseConfig } from './components/BlockDispatcher/config'
|
package/src/types/block.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import type { DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'
|
|
3
|
-
import type { Nullable } from '@okam/stack-ui'
|
|
4
|
-
import type { Variables } from 'graphql-request'
|
|
5
|
-
import type { FragmentType } from '../generated/fragment-masking'
|
|
6
|
-
import type { BlockSettingsFragment } from '../generated/graphql'
|
|
7
|
-
|
|
8
|
-
export type TAdditionalProps = { [key: string]: unknown }
|
|
9
|
-
|
|
10
|
-
type BlockSettings = FragmentType<DocumentTypeDecoration<BlockSettingsFragment, unknown>>
|
|
11
|
-
|
|
12
|
-
export type TCommonBlockFragment = {
|
|
13
|
-
id?: Nullable<string>
|
|
14
|
-
settings?: Nullable<BlockSettings>
|
|
15
|
-
} & Record<string, unknown>
|
|
16
|
-
|
|
17
|
-
export type TBlockQuery<BlockFragment extends TCommonBlockFragment> = {
|
|
18
|
-
__typename?: 'Query'
|
|
19
|
-
} & {
|
|
20
|
-
[blockKey: string]:
|
|
21
|
-
| {
|
|
22
|
-
' $fragmentRefs'?:
|
|
23
|
-
| {
|
|
24
|
-
[blockFragmentKey: string]: BlockFragment
|
|
25
|
-
}
|
|
26
|
-
| null
|
|
27
|
-
| undefined
|
|
28
|
-
}
|
|
29
|
-
| null
|
|
30
|
-
| undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type TBlockVariables<BlockVariables extends Variables = Variables> = {
|
|
34
|
-
id: string
|
|
35
|
-
} & BlockVariables
|
|
36
|
-
|
|
37
|
-
export type TBlockDocument<
|
|
38
|
-
BlockFragment extends TCommonBlockFragment,
|
|
39
|
-
BlockVariables extends Variables = Variables,
|
|
40
|
-
> = TypedDocumentNode<TBlockQuery<BlockFragment>, TBlockVariables<BlockVariables>>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'server-only'
|
|
2
|
-
|
|
3
|
-
import { queryGql } from '@okam/directus-query'
|
|
4
|
-
import type { Nullable } from '@okam/stack-ui'
|
|
5
|
-
import type { Variables } from 'graphql-request'
|
|
6
|
-
import type { TBlockDocument, TBlockQuery, TBlockVariables, TCommonBlockFragment } from '../types/block'
|
|
7
|
-
|
|
8
|
-
type TGetBlockPropsParams<BlockFragment extends TCommonBlockFragment, BlockVariables extends Variables = Variables> = {
|
|
9
|
-
document?: TBlockDocument<BlockFragment, BlockVariables>
|
|
10
|
-
item?: Nullable<NonNullable<NonNullable<TBlockQuery<BlockFragment>[string]>[' $fragmentRefs']>[string]>
|
|
11
|
-
blockKey?: string
|
|
12
|
-
variables?: TBlockVariables<BlockVariables>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function isVariables<BlockVariables extends Variables>(
|
|
16
|
-
maybeVariables: Nullable<Variables>,
|
|
17
|
-
): maybeVariables is BlockVariables {
|
|
18
|
-
return !!maybeVariables
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Returns the passed item if it is defined. Otherwise, queried its own block
|
|
23
|
-
* @param params.blockKey Key of the queried field
|
|
24
|
-
* @param params.item Item of the block. If null, the function will make a query
|
|
25
|
-
* @returns The block data
|
|
26
|
-
*/
|
|
27
|
-
export default async function getBlockProps<
|
|
28
|
-
BlockFragment extends TCommonBlockFragment,
|
|
29
|
-
BlockVariables extends Variables = Variables,
|
|
30
|
-
>(params: TGetBlockPropsParams<BlockFragment, BlockVariables>): Promise<BlockFragment | null | undefined> {
|
|
31
|
-
const { document, item, blockKey, variables } = params
|
|
32
|
-
|
|
33
|
-
if (item) return item
|
|
34
|
-
|
|
35
|
-
if (!document || !isVariables<BlockVariables>(variables)) return null
|
|
36
|
-
|
|
37
|
-
const queriedBlockProps = await queryGql(document, variables)
|
|
38
|
-
|
|
39
|
-
if (!queriedBlockProps || typeof queriedBlockProps !== 'object' || !blockKey) return null
|
|
40
|
-
|
|
41
|
-
const queriedBlockFragment = queriedBlockProps[blockKey]
|
|
42
|
-
|
|
43
|
-
return queriedBlockFragment as BlockFragment
|
|
44
|
-
}
|
package/src/utils/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Nullable } from '@okam/stack-ui'
|
|
2
|
-
import type { TBlockSerializerConfig } from '../components/BlockSerializer/interface'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Merges multiple block dispatcher configs
|
|
6
|
-
* @param baseConfig The base configuration. Other configurations will be prioritized over this one, which acts as a fallback
|
|
7
|
-
* @param configs Array of block dispatcher serializers to merge. Later elements will always be prioritized over first elements
|
|
8
|
-
* @returns Merged config
|
|
9
|
-
*/
|
|
10
|
-
export default function mergeConfigs(
|
|
11
|
-
baseConfig: TBlockSerializerConfig,
|
|
12
|
-
...configs: Nullable<TBlockSerializerConfig>[]
|
|
13
|
-
): TBlockSerializerConfig {
|
|
14
|
-
const finalConfig = configs.reduce<TBlockSerializerConfig>((mergedConfig, config) => {
|
|
15
|
-
if (!config) return mergedConfig
|
|
16
|
-
|
|
17
|
-
return { components: { ...mergedConfig.components, ...config.components } }
|
|
18
|
-
}, baseConfig)
|
|
19
|
-
|
|
20
|
-
return finalConfig
|
|
21
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"jsx": "react-jsx",
|
|
4
|
-
"allowJs": false,
|
|
5
|
-
"esModuleInterop": false,
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"strict": true
|
|
8
|
-
},
|
|
9
|
-
"files": [],
|
|
10
|
-
"include": [],
|
|
11
|
-
"references": [
|
|
12
|
-
{
|
|
13
|
-
"path": "./tsconfig.lib.json"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "./.storybook/tsconfig.json"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"extends": "../../../tsconfig.base.json"
|
|
20
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../../dist/out-tsc",
|
|
5
|
-
"types": ["node", "next"]
|
|
6
|
-
},
|
|
7
|
-
"paths": { "@workspace/*": ["dist/libs/*"] },
|
|
8
|
-
"files": [
|
|
9
|
-
"../../../node_modules/@nx/react/typings/cssmodule.d.ts",
|
|
10
|
-
"../../../node_modules/@nx/react/typings/image.d.ts"
|
|
11
|
-
],
|
|
12
|
-
"exclude": [
|
|
13
|
-
"**/*.spec.ts",
|
|
14
|
-
"**/*.test.ts",
|
|
15
|
-
"**/*.spec.tsx",
|
|
16
|
-
"**/*.test.tsx",
|
|
17
|
-
"**/*.spec.js",
|
|
18
|
-
"**/*.test.js",
|
|
19
|
-
"**/*.spec.jsx",
|
|
20
|
-
"**/*.test.jsx",
|
|
21
|
-
"**/*.stories.ts",
|
|
22
|
-
"**/*.stories.js"
|
|
23
|
-
],
|
|
24
|
-
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
|
|
25
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-relative-packages */
|
|
2
|
-
/// <reference types="vitest" />
|
|
3
|
-
import * as path from 'path'
|
|
4
|
-
import react from '@vitejs/plugin-react'
|
|
5
|
-
import { defineConfig } from 'vite'
|
|
6
|
-
import dts from 'vite-plugin-dts'
|
|
7
|
-
import viteTsConfigPaths from 'vite-tsconfig-paths'
|
|
8
|
-
import externalDeps from '../../../config/external-deps'
|
|
9
|
-
|
|
10
|
-
export default defineConfig({
|
|
11
|
-
cacheDir: '../../../node_modules/.vite/directus-block',
|
|
12
|
-
|
|
13
|
-
plugins: [
|
|
14
|
-
dts({
|
|
15
|
-
entryRoot: 'src',
|
|
16
|
-
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
17
|
-
skipDiagnostics: true,
|
|
18
|
-
}),
|
|
19
|
-
react(),
|
|
20
|
-
viteTsConfigPaths({
|
|
21
|
-
root: '../../../',
|
|
22
|
-
}),
|
|
23
|
-
],
|
|
24
|
-
|
|
25
|
-
// Uncomment this if you are using workers.
|
|
26
|
-
// worker: {
|
|
27
|
-
// plugins: [
|
|
28
|
-
// viteTsConfigPaths({
|
|
29
|
-
// root: '../../../',
|
|
30
|
-
// }),
|
|
31
|
-
// ],
|
|
32
|
-
// },
|
|
33
|
-
|
|
34
|
-
// Configuration for building your library.
|
|
35
|
-
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
36
|
-
build: {
|
|
37
|
-
lib: {
|
|
38
|
-
// Could also be a dictionary or array of multiple entry points.
|
|
39
|
-
entry: 'src/index.ts',
|
|
40
|
-
name: 'directus-block',
|
|
41
|
-
fileName: 'index',
|
|
42
|
-
// Change this to the formats you want to support.
|
|
43
|
-
// Don't forget to update your package.json as well.
|
|
44
|
-
formats: ['es', 'cjs'],
|
|
45
|
-
},
|
|
46
|
-
rollupOptions: {
|
|
47
|
-
// External packages that should not be bundled into your library.
|
|
48
|
-
external: externalDeps,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
})
|