@digo-labs/common 0.1.10 → 0.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digo-labs/common",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -17,21 +17,17 @@
17
17
  "development": "./src/index.css",
18
18
  "default": "./dist/index.css"
19
19
  },
20
- "./vite.apps": "./vite.apps.ts",
21
- "./vite-plugin-raw-mdx": "./vite-plugin-raw-mdx.ts",
22
20
  "./package.json": "./package.json"
23
21
  },
24
22
  "files": [
25
- "dist",
26
- "vite.apps.ts",
27
- "vite-plugin-raw-mdx.ts"
23
+ "dist"
28
24
  ],
29
25
  "publishConfig": {
30
26
  "access": "public",
31
27
  "registry": "https://registry.npmjs.org/"
32
28
  },
33
29
  "scripts": {
34
- "build": "vite build && cp src/index.css dist/index.css",
30
+ "build": "vite build",
35
31
  "lint": "eslint ./src",
36
32
  "lint:fix": "eslint ./src --fix"
37
33
  },
@@ -59,6 +55,6 @@
59
55
  },
60
56
  "devDependencies": {
61
57
  "@digo-labs/dev-dependencies": "*",
62
- "vite-multiple-assets": "^2.2.5"
58
+ "@digo-labs/vite-config": "*"
63
59
  }
64
60
  }
@@ -1,63 +0,0 @@
1
- import { readdirSync, readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import type { Plugin } from 'vite';
4
-
5
- type RawMdxConfig = { docsDir: string; };
6
-
7
- function extractSection(content: string): string {
8
- const match = content.match(/^section:\s*(.+)$/m);
9
- return match?.[1].trim().replace(/['"]/g, '') ?? 'Uncategorized';
10
- }
11
-
12
- function toSlug(name: string): string {
13
- return name.toLowerCase().replace(/\s+/g, '-');
14
- }
15
-
16
- export function rawMdxPlugin(config: RawMdxConfig): Plugin {
17
- const { docsDir } = config;
18
-
19
- return {
20
- name: 'vite-plugin-raw-mdx',
21
-
22
- configureServer(server) {
23
- server.middlewares.use((req, res, next) => {
24
- const match = req.url?.match(/^\/docs\/([^/]+)\/([^/]+)\.mdx(\?.*)?$/);
25
- if (!match) return next();
26
-
27
- const [, sectionSlug, slug] = match;
28
- const filePath = join(docsDir, `${slug}.mdx`);
29
-
30
- try {
31
- const content = readFileSync(filePath, 'utf8');
32
- const expectedSlug = toSlug(extractSection(content));
33
-
34
- if (expectedSlug !== sectionSlug) {
35
- res.statusCode = 404;
36
- res.end('Not found');
37
- return;
38
- }
39
-
40
- res.setHeader('Content-Type', 'text/plain; charset=utf-8');
41
- res.end(content);
42
- } catch {
43
- next();
44
- }
45
- });
46
- },
47
-
48
- generateBundle() {
49
- const files = readdirSync(docsDir).filter(f => f.endsWith('.mdx'));
50
-
51
- for (const file of files) {
52
- const content = readFileSync(join(docsDir, file), 'utf8');
53
- const sectionSlug = toSlug(extractSection(content));
54
-
55
- this.emitFile({
56
- type: 'asset',
57
- fileName: `docs/${sectionSlug}/${file}`,
58
- source: content,
59
- });
60
- }
61
- },
62
- };
63
- }
package/vite.apps.ts DELETED
@@ -1,54 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- import react from '@vitejs/plugin-react';
3
- import tailwindcss from '@tailwindcss/vite';
4
- import tsconfigPaths from 'vite-tsconfig-paths';
5
- import { DynamicPublicDirectory } from 'vite-multiple-assets';
6
- import svgr from 'vite-plugin-svgr';
7
- import mdx from '@mdx-js/rollup';
8
- import remarkGfm from 'remark-gfm';
9
- import remarkFrontmatter from 'remark-frontmatter';
10
- import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
11
- import rehypeSlug from 'rehype-slug';
12
- import { resolve } from 'node:path';
13
- import { rawMdxPlugin } from './vite-plugin-raw-mdx';
14
-
15
- export type DigoViteConfigProperties = {
16
- includeAssetsFrom: string[];
17
- port: number;
18
- allowedHosts?: string[];
19
- docsDir?: string;
20
- };
21
-
22
- export function digoViteConfig(properties: DigoViteConfigProperties) {
23
- const { includeAssetsFrom, port, allowedHosts, docsDir } = properties;
24
- return defineConfig({
25
- plugins: [
26
- react({
27
- babel: {
28
- plugins: ['module:@preact/signals-react-transform'],
29
- },
30
- }),
31
- tailwindcss(),
32
- tsconfigPaths(),
33
- DynamicPublicDirectory(
34
- includeAssetsFrom.map(mod => `../../${mod}/public/**`),
35
- ),
36
- svgr(),
37
- mdx({
38
- providerImportSource: '@mdx-js/react',
39
- remarkPlugins: [remarkGfm, remarkFrontmatter, remarkMdxFrontmatter],
40
- rehypePlugins: [rehypeSlug],
41
-
42
- }),
43
- ...docsDir ? [rawMdxPlugin({ docsDir: resolve(process.cwd(), docsDir) })] : [],
44
- ],
45
- server: {
46
- port: port,
47
- allowedHosts: allowedHosts,
48
- },
49
- build: {
50
- chunkSizeWarningLimit: 10000,
51
- },
52
- assetsInclude: ['**/*.tsx?raw', '**/*.html?raw', '**/*.ts?raw', '**/*.css?raw', '**/*.json?raw'],
53
- });
54
- }