tonka-vite-plugin 1.21.0 → 1.30.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.
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'vite';
2
+ import { TonkaPluginOptions } from '../types';
3
+ export default function tonkaPlugin(options?: TonkaPluginOptions): Plugin;
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import path from 'path';
2
+ export default function tonkaPlugin(options = {}) {
3
+ const root = process.cwd();
4
+ return {
5
+ name: 'tonka-vite-plugin',
6
+ config: (userConfig, { command }) => {
7
+ const input = options.input || {
8
+ 'resources/css/app.css': undefined,
9
+ 'resources/js/app.tsx': undefined,
10
+ };
11
+ const outDir = options.outDir || path.resolve(root, 'public/build');
12
+ const manifest = options.manifest !== false ? 'manifest.json' : false;
13
+ const ssrBuild = options.ssr ? options.ssr : false;
14
+ return {
15
+ build: {
16
+ outDir: outDir,
17
+ manifest: manifest,
18
+ assetsDir: options.assetsDir || 'assets',
19
+ rollupOptions: {
20
+ input: input,
21
+ },
22
+ ssr: ssrBuild,
23
+ sourcemap: command === 'serve',
24
+ },
25
+ resolve: {
26
+ alias: options.alias || {
27
+ '@': path.resolve(root, '.'),
28
+ },
29
+ },
30
+ optimizeDeps: {
31
+ include: ['react', 'react-dom', '@inertiajs/react', 'axios'],
32
+ exclude: [],
33
+ },
34
+ };
35
+ },
36
+ transformIndexHtml(html) {
37
+ if (options.refresh) {
38
+ }
39
+ return html;
40
+ },
41
+ };
42
+ }
package/package.json CHANGED
@@ -1,10 +1,22 @@
1
1
  {
2
2
  "name": "tonka-vite-plugin",
3
- "version": "1.21.0",
3
+ "version": "1.30.0",
4
4
  "description": "A Vite plugin for Inertia.js that provides automatic page imports and enhanced development experience.",
5
- "main": "index.ts",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "types"
13
+ ],
6
14
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
15
+ "build": "tsc"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^5.0.0",
19
+ "vite": "^5.0.0"
8
20
  },
9
21
  "repository": {
10
22
  "type": "git",
package/bin/index.ts DELETED
@@ -1,101 +0,0 @@
1
- import type { Plugin, UserConfig } from 'vite';
2
- import { fileURLToPath, URL } from 'node:url';
3
- import path from 'path';
4
- import { TonkaPluginOptions } from '../lib';
5
-
6
- /**
7
- * Tonka Vite Plugin
8
- *
9
- * A Vite plugin specifically designed for the Tonka Framework.
10
- * It automates the configuration for Inertia.js, SSR, and asset paths.
11
- *
12
- * @param options - Configuration options for the plugin
13
- * @returns A Vite plugin object
14
- */
15
- export default function tonkaPlugin(options: TonkaPluginOptions = {}): Plugin {
16
- // Determine the base directory of the project
17
- const root = process.cwd();
18
-
19
- return {
20
- name: 'tonka-vite-plugin',
21
-
22
- /**
23
- * The `config` hook is called before the user config is resolved.
24
- * We use it to inject default settings and handle the Tonka-specific structure.
25
- */
26
- config: (userConfig: UserConfig, { command }) => {
27
- // 1. Handle Inputs
28
- // If the user doesn't provide inputs, we assume the standard structure.
29
- // Note: We cast to 'any' here to satisfy Rollup's strict typing for input.
30
- const input: any = options.input || {
31
- 'resources/css/app.css': undefined, // CSS entry
32
- 'resources/js/app.tsx': undefined, // Main JS entry
33
- };
34
-
35
- // 2. Handle Output Directory
36
- // Default to 'public/build' if not specified
37
- const outDir = options.outDir || path.resolve(root, 'public/build');
38
-
39
- // 3. Handle Manifest
40
- // Ensure manifest is generated unless explicitly disabled
41
- const manifest = options.manifest !== false ? 'manifest.json' : false;
42
-
43
- // 4. Handle SSR
44
- // If ssr is false, we ensure we don't set the ssr config.
45
- const ssrBuild = options.ssr ? options.ssr : false;
46
-
47
- return {
48
- build: {
49
- outDir: outDir,
50
- manifest: manifest,
51
- assetsDir: options.assetsDir || 'assets',
52
-
53
- // Rollup options
54
- rollupOptions: {
55
- input: input,
56
- },
57
-
58
- // Server-Side Rendering configuration
59
- ssr: ssrBuild,
60
-
61
- // Source maps: enabled in dev, disabled in prod (optional optimization)
62
- sourcemap: command === 'serve',
63
- },
64
-
65
- // 5. Resolve Aliases
66
- resolve: {
67
- // Merge user aliases with defaults
68
- alias: options.alias || {
69
- // Default alias: '@' points to the root of the project
70
- // You can also point it to 'resources' or 'public' based on your preference.
71
- '@': path.resolve(root, '.'),
72
- },
73
- },
74
-
75
- // 6. Optimize dependencies
76
- // Pre-bundle common dependencies to speed up dev server start
77
- optimizeDeps: {
78
- include: ['react', 'react-dom', '@inertiajs/react', 'axios'],
79
- exclude: [],
80
- },
81
- };
82
- },
83
-
84
- /**
85
- * The `transformIndexHtml` hook allows modifying the HTML index file.
86
- * This can be used to inject the @vite/client script for HMR if needed.
87
- */
88
- transformIndexHtml(html) {
89
- // If refresh is enabled, we could inject the HMR client here.
90
- // However, in a typical Inertia setup (like Tonka), this is often
91
- // handled by the server-side Blade/PHP template (@vite directive).
92
- // We leave this placeholder for future enhancements.
93
- if (options.refresh) {
94
- // Implementation note: Injecting @vite/client usually requires
95
- // knowing the exact module path, which varies.
96
- // For now, we trust the server-side directive.
97
- }
98
- return html;
99
- },
100
- };
101
- }
package/index.ts DELETED
@@ -1,2 +0,0 @@
1
- import tonkaPlugin from './bin';
2
- export default tonkaPlugin;
File without changes