@adonisjs/vite 2.0.2 → 3.0.0-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.
Files changed (38) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/index.d.ts +2 -2
  3. package/build/index.js +2 -2
  4. package/build/providers/vite_provider.d.ts +4 -10
  5. package/build/providers/vite_provider.js +22 -53
  6. package/build/services/vite.d.ts +1 -1
  7. package/build/src/client/config.d.ts +13 -2
  8. package/build/src/client/config.js +36 -42
  9. package/build/src/client/main.d.ts +1 -1
  10. package/build/src/client/main.js +4 -6
  11. package/build/src/client/types.d.ts +12 -21
  12. package/build/src/define_config.d.ts +5 -0
  13. package/build/src/{backend/define_config.js → define_config.js} +1 -2
  14. package/build/src/hooks/build_hook.d.ts +8 -0
  15. package/build/src/hooks/build_hook.js +25 -0
  16. package/build/src/middlewares/vite_middleware.d.ts +17 -0
  17. package/build/src/middlewares/vite_middleware.js +31 -0
  18. package/build/src/{backend/plugins → plugins}/edge.js +2 -4
  19. package/build/src/{backend/types.d.ts → types.d.ts} +6 -22
  20. package/build/src/{backend/utils.d.ts → utils.d.ts} +4 -0
  21. package/build/src/{backend/utils.js → utils.js} +6 -0
  22. package/build/src/{backend/vite.d.ts → vite.d.ts} +27 -9
  23. package/build/src/{backend/vite.js → vite.js} +106 -104
  24. package/build/stubs/vite.config.stub +1 -1
  25. package/package.json +36 -56
  26. package/build/src/backend/debug.d.ts +0 -3
  27. package/build/src/backend/debug.js +0 -10
  28. package/build/src/backend/define_config.d.ts +0 -5
  29. package/build/src/client/config_resolver.d.ts +0 -20
  30. package/build/src/client/config_resolver.js +0 -46
  31. package/build/src/client/helpers/inertia.d.ts +0 -4
  32. package/build/src/client/helpers/inertia.js +0 -22
  33. package/build/src/client/hot_file.d.ts +0 -14
  34. package/build/src/client/hot_file.js +0 -49
  35. package/build/src/client/utils.d.ts +0 -11
  36. package/build/src/client/utils.js +0 -44
  37. /package/build/src/{backend/plugins → plugins}/edge.d.ts +0 -0
  38. /package/build/src/{backend/types.js → types.js} +0 -0
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The MIT License
2
2
 
3
- Copyright 2022 Harminder Virk, contributors
3
+ Copyright (c) 2023
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
+ export { Vite } from './src/vite.js';
1
2
  export { configure } from './configure.js';
2
- export { Vite } from './src/backend/vite.js';
3
3
  export { stubsRoot } from './stubs/main.js';
4
- export { defineConfig } from './src/backend/define_config.js';
4
+ export { defineConfig } from './src/define_config.js';
package/build/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
+ export { Vite } from './src/vite.js';
9
10
  export { configure } from './configure.js';
10
- export { Vite } from './src/backend/vite.js';
11
11
  export { stubsRoot } from './stubs/main.js';
12
- export { defineConfig } from './src/backend/define_config.js';
12
+ export { defineConfig } from './src/define_config.js';
@@ -1,24 +1,18 @@
1
1
  import type { ApplicationService } from '@adonisjs/core/types';
2
- import { Vite } from '../src/backend/vite.js';
3
- /**
4
- * Extend the container bindings
5
- */
2
+ import { Vite } from '../src/vite.js';
6
3
  declare module '@adonisjs/core/types' {
7
4
  interface ContainerBindings {
8
5
  vite: Vite;
9
6
  }
10
7
  }
11
- export default class ViteServiceProvider {
8
+ export default class ViteProvider {
12
9
  protected app: ApplicationService;
13
10
  constructor(app: ApplicationService);
14
11
  /**
15
12
  * Registers edge plugin when edge is installed
16
13
  */
17
14
  protected registerEdgePlugin(): Promise<void>;
18
- /**
19
- * Registers CSP keywords when @adonisjs/shield is installed
20
- */
21
- protected registerShieldKeywords(): Promise<void>;
22
- register(): void;
15
+ register(): Promise<void>;
23
16
  boot(): Promise<void>;
17
+ shutdown(): Promise<void>;
24
18
  }
@@ -6,10 +6,9 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import debug from '../src/backend/debug.js';
10
- import { Vite } from '../src/backend/vite.js';
11
- import { defineConfig } from '../src/backend/define_config.js';
12
- export default class ViteServiceProvider {
9
+ import { Vite } from '../src/vite.js';
10
+ import ViteMiddleware from '../src/middlewares/vite_middleware.js';
11
+ export default class ViteProvider {
13
12
  app;
14
13
  constructor(app) {
15
14
  this.app = app;
@@ -21,60 +20,30 @@ export default class ViteServiceProvider {
21
20
  if (this.app.usingEdgeJS) {
22
21
  const edge = await import('edge.js');
23
22
  const vite = await this.app.container.make('vite');
24
- const { edgePluginVite } = await import('../src/backend/plugins/edge.js');
23
+ const { edgePluginVite } = await import('../src/plugins/edge.js');
25
24
  edge.default.use(edgePluginVite(vite));
26
25
  }
27
26
  }
28
- /**
29
- * Registers CSP keywords when @adonisjs/shield is installed
30
- */
31
- async registerShieldKeywords() {
32
- let cspKeywords = null;
33
- try {
34
- const shieldExports = await import('@adonisjs/shield');
35
- cspKeywords = shieldExports.cspKeywords;
36
- }
37
- catch { }
38
- if (cspKeywords) {
39
- debug('Detected @adonisjs/shield package. Adding Vite keywords for CSP policy');
40
- const vite = await this.app.container.make('vite');
41
- /**
42
- * Registering the @viteUrl keyword for CSP directives.
43
- * Returns http URL to the dev or the CDN server, otherwise
44
- * an empty string
45
- */
46
- cspKeywords.register('@viteUrl', function () {
47
- const assetsURL = vite.assetsUrl();
48
- if (!assetsURL || !assetsURL.startsWith('http://') || assetsURL.startsWith('https://')) {
49
- return '';
50
- }
51
- return assetsURL;
52
- });
53
- /**
54
- * Registering the @viteDevUrl keyword for the CSP directives.
55
- * Returns the dev server URL in development and empty string
56
- * in prod
57
- */
58
- cspKeywords.register('@viteDevUrl', function () {
59
- return vite.devUrl();
60
- });
61
- /**
62
- * Registering the @viteHmrUrl keyword for the CSP directives.
63
- * Returns the Websocket URL for the HMR server
64
- */
65
- cspKeywords.register('@viteHmrUrl', function () {
66
- return vite.devUrl().replace('http://', 'ws://').replace('https://', 'wss://');
67
- });
27
+ async register() {
28
+ const config = this.app.config.get('vite');
29
+ const vite = new Vite(this.app.inDev, config);
30
+ this.app.container.bind('vite', () => vite);
31
+ this.app.container.bind(ViteMiddleware, () => new ViteMiddleware(vite));
32
+ if (this.app.inDev) {
33
+ const server = await this.app.container.make('server');
34
+ server.use([() => import('../src/middlewares/vite_middleware.js')]);
68
35
  }
69
36
  }
70
- register() {
71
- this.app.container.singleton('vite', async () => {
72
- const config = this.app.config.get('vite', defineConfig({}));
73
- return new Vite(config);
74
- });
75
- }
76
37
  async boot() {
77
- await this.registerEdgePlugin();
78
- await this.registerShieldKeywords();
38
+ if (!this.app.inDev)
39
+ return;
40
+ const vite = await this.app.container.make('vite');
41
+ await Promise.all([vite.createDevServer(), this.registerEdgePlugin()]);
42
+ }
43
+ async shutdown() {
44
+ if (!this.app.inDev)
45
+ return;
46
+ const vite = await this.app.container.make('vite');
47
+ await vite.stopDevServer();
79
48
  }
80
49
  }
@@ -1,3 +1,3 @@
1
- import type { Vite } from '../src/backend/vite.js';
1
+ import type { Vite } from '../src/vite.js';
2
2
  declare let vite: Vite;
3
3
  export { vite as default };
@@ -1,9 +1,20 @@
1
- import { ConfigEnv, Plugin, UserConfig } from 'vite';
1
+ import type { AliasOptions, ConfigEnv, Plugin, UserConfig } from 'vite';
2
2
  import type { PluginFullOptions } from './types.js';
3
+ /**
4
+ * Resolve the `config.resolve.alias` value
5
+ *
6
+ * Basically we are merging the user defined alias with the
7
+ * default alias.
8
+ */
9
+ export declare function resolveAlias(config: UserConfig): AliasOptions;
10
+ /**
11
+ * Resolve the `config.base` value
12
+ */
13
+ export declare function resolveBase(config: UserConfig, options: PluginFullOptions, command: 'build' | 'serve'): string;
3
14
  /**
4
15
  * Vite config hook
5
16
  */
6
- export declare const configHook: (options: PluginFullOptions, userConfig: UserConfig, { command }: ConfigEnv) => UserConfig;
17
+ export declare function configHook(options: PluginFullOptions, userConfig: UserConfig, { command }: ConfigEnv): UserConfig;
7
18
  /**
8
19
  * Update the user vite config to match the Adonis requirements
9
20
  */
@@ -6,68 +6,62 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import { defu } from 'defu';
10
9
  import { join } from 'node:path';
11
- import { HotFile } from './hot_file.js';
12
- import { resolveDevServerUrl } from './utils.js';
13
- import { ConfigResolver } from './config_resolver.js';
10
+ import { addTrailingSlash } from '../utils.js';
11
+ /**
12
+ * Resolve the `config.resolve.alias` value
13
+ *
14
+ * Basically we are merging the user defined alias with the
15
+ * default alias.
16
+ */
17
+ export function resolveAlias(config) {
18
+ const defaultAlias = { '@/': `/resources/js/` };
19
+ if (Array.isArray(config.resolve?.alias)) {
20
+ return [
21
+ ...(config.resolve?.alias ?? []),
22
+ Object.entries(defaultAlias).map(([find, replacement]) => ({ find, replacement })),
23
+ ];
24
+ }
25
+ return { ...defaultAlias, ...config.resolve?.alias };
26
+ }
27
+ /**
28
+ * Resolve the `config.base` value
29
+ */
30
+ export function resolveBase(config, options, command) {
31
+ if (config.base)
32
+ return config.base;
33
+ if (command === 'build') {
34
+ return addTrailingSlash(options.assetsUrl);
35
+ }
36
+ return '/';
37
+ }
14
38
  /**
15
39
  * Vite config hook
16
40
  */
17
- export const configHook = (options, userConfig, { command }) => {
41
+ export function configHook(options, userConfig, { command }) {
18
42
  const config = {
19
43
  publicDir: userConfig.publicDir ?? false,
20
- base: ConfigResolver.resolveBase(userConfig, options, command),
21
- resolve: { alias: ConfigResolver.resolveAlias(userConfig) },
22
- server: {
23
- /**
24
- * Will allow to rewrite the URL to the public path
25
- * in dev mode
26
- */
27
- origin: '__adonis_vite__',
28
- },
44
+ resolve: { alias: resolveAlias(userConfig) },
45
+ base: resolveBase(userConfig, options, command),
29
46
  build: {
30
47
  assetsDir: '',
31
- manifest: userConfig.build?.manifest ?? true,
32
48
  emptyOutDir: true,
33
- outDir: ConfigResolver.resolveOutDir(userConfig, options),
49
+ manifest: userConfig.build?.manifest ?? true,
50
+ outDir: userConfig.build?.outDir ?? options.buildDirectory,
51
+ assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0,
34
52
  rollupOptions: {
35
53
  input: options.entrypoints.map((entrypoint) => join(userConfig.root || '', entrypoint)),
36
54
  },
37
55
  },
38
56
  };
39
- return defu(config, userConfig);
40
- };
57
+ return config;
58
+ }
41
59
  /**
42
60
  * Update the user vite config to match the Adonis requirements
43
61
  */
44
62
  export const config = (options) => {
45
- let devServerUrl;
46
63
  return {
47
64
  name: 'vite-plugin-adonis:config',
48
65
  config: configHook.bind(null, options),
49
- /**
50
- * Store the dev server url for further usage when rewriting URLs
51
- */
52
- configureServer(server) {
53
- const hotfile = new HotFile(options.hotFile);
54
- server.httpServer?.once('listening', async () => {
55
- devServerUrl = resolveDevServerUrl(server.httpServer.address(), server.config);
56
- await hotfile.write({ url: devServerUrl });
57
- });
58
- server.httpServer?.on('close', () => hotfile.clean());
59
- },
60
- /**
61
- * Rewrite URL to the public path in dev mode
62
- *
63
- * See : https://nystudio107.com/blog/using-vite-js-next-generation-frontend-tooling-with-craft-cms#vite-processed-assets
64
- */
65
- transform: (code) => ({
66
- code: code.replace(/__adonis_vite__/g, devServerUrl),
67
- map: null,
68
- }),
69
- configResolved: async (resolvedConfig) => {
70
- ConfigResolver.resolvedConfig = resolvedConfig;
71
- },
72
66
  };
73
67
  };
@@ -6,6 +6,6 @@ declare module 'vite' {
6
6
  }
7
7
  }
8
8
  /**
9
- * Vite plugin for adonisjs
9
+ * Vite plugin for AdonisJS
10
10
  */
11
11
  export default function adonisjs(options: PluginOptions): PluginOption[];
@@ -6,18 +6,16 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import { defu } from 'defu';
10
9
  import PluginRestart from 'vite-plugin-restart';
11
10
  import { config } from './config.js';
12
11
  /**
13
- * Vite plugin for adonisjs
12
+ * Vite plugin for AdonisJS
14
13
  */
15
14
  export default function adonisjs(options) {
16
- const fullOptions = defu(options, {
17
- buildDirectory: 'public/assets',
15
+ const fullOptions = Object.assign({
18
16
  assetsUrl: '/assets',
19
- hotFile: 'public/assets/hot.json',
17
+ buildDirectory: 'public/assets',
20
18
  reload: ['./resources/views/**/*.edge'],
21
- });
19
+ }, options);
22
20
  return [PluginRestart({ reload: fullOptions.reload }), config(fullOptions)];
23
21
  }
@@ -1,17 +1,4 @@
1
- /**
2
- * Possible plugin options
3
- */
4
- export type PluginOptions = {
5
- /**
6
- * Path to the hot file
7
- *
8
- * @default public/hot.json
9
- */
10
- hotFile?: string;
11
- /**
12
- * Paths to the entrypoints files
13
- */
14
- entrypoints: string[];
1
+ export interface PluginOptions {
15
2
  /**
16
3
  * The URL where the assets will be served. This is particularly
17
4
  * useful if you are using a CDN to deploy your assets.
@@ -19,17 +6,21 @@ export type PluginOptions = {
19
6
  * @default ''
20
7
  */
21
8
  assetsUrl?: string;
22
- /**
23
- * Public directory where the assets will be compiled.
24
- *
25
- * @default 'public/assets'
26
- */
27
- buildDirectory?: string;
28
9
  /**
29
10
  * Files that should trigger a page reload when changed.
30
11
  *
31
12
  * @default ['./resources/views/** /*.edge']
32
13
  */
33
14
  reload?: string[];
34
- };
15
+ /**
16
+ * Paths to the entrypoints files
17
+ */
18
+ entrypoints: string[];
19
+ /**
20
+ * Public directory where the assets will be compiled.
21
+ *
22
+ * @default 'public/assets'
23
+ */
24
+ buildDirectory?: string;
25
+ }
35
26
  export type PluginFullOptions = Required<PluginOptions>;
@@ -0,0 +1,5 @@
1
+ import type { ViteOptions } from './types.js';
2
+ /**
3
+ * Define the backend config for Vite
4
+ */
5
+ export declare function defineConfig(config: Partial<ViteOptions>): ViteOptions;
@@ -8,12 +8,11 @@
8
8
  */
9
9
  import { join } from 'node:path';
10
10
  /**
11
- * Define the backend config for resolving vite assets
11
+ * Define the backend config for Vite
12
12
  */
13
13
  export function defineConfig(config) {
14
14
  return {
15
15
  buildDirectory: 'public/assets',
16
- hotFile: 'public/assets/hot.json',
17
16
  assetsUrl: '/assets',
18
17
  manifestFile: config.buildDirectory
19
18
  ? join(config.buildDirectory, '.vite/manifest.json')
@@ -0,0 +1,8 @@
1
+ import type { AssemblerHookHandler } from '@adonisjs/application/types';
2
+ /**
3
+ * This is an Assembler hook that should be executed when the application is
4
+ * builded using the `node ace build` command.
5
+ *
6
+ * The hook is responsible for launching a Vite multi-build process.
7
+ */
8
+ export default function viteBuildHook({ logger }: Parameters<AssemblerHookHandler>[0]): Promise<void>;
@@ -0,0 +1,25 @@
1
+ /*
2
+ * @adonisjs/vite
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import { multibuild } from '@vavite/multibuild';
10
+ /**
11
+ * This is an Assembler hook that should be executed when the application is
12
+ * builded using the `node ace build` command.
13
+ *
14
+ * The hook is responsible for launching a Vite multi-build process.
15
+ */
16
+ export default async function viteBuildHook({ logger }) {
17
+ logger.info('building assets with vite');
18
+ await multibuild(undefined, {
19
+ onStartBuildStep: (step) => {
20
+ if (!step.currentStep.description)
21
+ return;
22
+ logger.info(step.currentStep.description);
23
+ },
24
+ });
25
+ }
@@ -0,0 +1,17 @@
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ import type { NextFn } from '@adonisjs/core/types/http';
3
+ import type { Vite } from '../vite.js';
4
+ /**
5
+ * Since Vite dev server is integrated within the AdonisJS process, this
6
+ * middleware is used to proxy the requests to it.
7
+ *
8
+ * Some of the requests are directly handled by the Vite dev server,
9
+ * like the one for the assets, while others are passed down to the
10
+ * AdonisJS server.
11
+ */
12
+ export default class ViteMiddleware {
13
+ #private;
14
+ protected vite: Vite;
15
+ constructor(vite: Vite);
16
+ handle({ request, response }: HttpContext, next: NextFn): Promise<unknown>;
17
+ }
@@ -0,0 +1,31 @@
1
+ /*
2
+ * @adonisjs/vite
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ /**
10
+ * Since Vite dev server is integrated within the AdonisJS process, this
11
+ * middleware is used to proxy the requests to it.
12
+ *
13
+ * Some of the requests are directly handled by the Vite dev server,
14
+ * like the one for the assets, while others are passed down to the
15
+ * AdonisJS server.
16
+ */
17
+ export default class ViteMiddleware {
18
+ vite;
19
+ #devServer;
20
+ constructor(vite) {
21
+ this.vite = vite;
22
+ this.#devServer = this.vite.getDevServer();
23
+ }
24
+ async handle({ request, response }, next) {
25
+ return await new Promise((resolve) => {
26
+ this.#devServer.middlewares.handle(request.request, response.response, () => {
27
+ return resolve(next());
28
+ });
29
+ });
30
+ }
31
+ }
@@ -7,17 +7,14 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  import { EdgeError } from 'edge-error';
10
- import debug from '../debug.js';
11
10
  /**
12
11
  * The edge plugin for vite to share vite service with edge
13
12
  * and register custom tags
14
13
  */
15
14
  export const edgePluginVite = (vite) => {
16
- return (edge) => {
17
- debug('sharing vite and asset globals with edge');
15
+ const edgeVite = (edge) => {
18
16
  edge.global('vite', vite);
19
17
  edge.global('asset', vite.assetPath.bind(vite));
20
- debug('registering vite tags with edge');
21
18
  edge.registerTag({
22
19
  tagName: 'viteReactRefresh',
23
20
  seekable: true,
@@ -83,4 +80,5 @@ export const edgePluginVite = (vite) => {
83
80
  },
84
81
  });
85
82
  };
83
+ return edgeVite;
86
84
  };
@@ -1,9 +1,3 @@
1
- /**
2
- * Contents of the hotfile
3
- */
4
- export type HotFile = {
5
- url: string;
6
- };
7
1
  /**
8
2
  * Parameters passed to the setAttributes callback
9
3
  */
@@ -28,17 +22,7 @@ export type AdonisViteElement = {
28
22
  attributes: Record<string, any>;
29
23
  children: string[];
30
24
  };
31
- /**
32
- * Vite backend integration configuration options
33
- */
34
- export type ViteOptions = {
35
- /**
36
- * Path to the hot file relative from the root of the
37
- * application.
38
- *
39
- * @default public/assets/hot.json
40
- */
41
- hotFile: string;
25
+ export interface ViteOptions {
42
26
  /**
43
27
  * Public directory where the assets will be compiled.
44
28
  *
@@ -61,12 +45,12 @@ export type ViteOptions = {
61
45
  assetsUrl?: string;
62
46
  /**
63
47
  * A custom set of attributes to apply on all
64
- * script tags
48
+ * script tags injected by edge `@vite` tag
65
49
  */
66
- scriptAttributes?: SetAttributes;
50
+ styleAttributes?: SetAttributes;
67
51
  /**
68
52
  * A custom set of attributes to apply on all
69
- * style tags
53
+ * style tags injected by edge `@vite` tag
70
54
  */
71
- styleAttributes?: SetAttributes;
72
- };
55
+ scriptAttributes?: SetAttributes;
56
+ }
@@ -6,3 +6,7 @@ export declare function uniqBy<T>(array: T[], key: keyof T): T[];
6
6
  * Convert Record of attributes to a valid HTML string
7
7
  */
8
8
  export declare function makeAttributes(attributes: Record<string, string | boolean>): string;
9
+ /**
10
+ * Add a trailing slash if missing
11
+ */
12
+ export declare const addTrailingSlash: (url: string) => string;
@@ -34,3 +34,9 @@ export function makeAttributes(attributes) {
34
34
  .filter((attr) => attr !== null)
35
35
  .join(' ');
36
36
  }
37
+ /**
38
+ * Add a trailing slash if missing
39
+ */
40
+ export const addTrailingSlash = (url) => {
41
+ return url.endsWith('/') ? url : url + '/';
42
+ };
@@ -1,4 +1,5 @@
1
- import type { Manifest } from 'vite';
1
+ import type { ViteRuntime } from 'vite/runtime';
2
+ import type { Manifest, ViteDevServer } from 'vite';
2
3
  import type { AdonisViteElement, ViteOptions } from './types.js';
3
4
  /**
4
5
  * Vite class exposes the APIs to generate tags and URLs for
@@ -6,22 +7,18 @@ import type { AdonisViteElement, ViteOptions } from './types.js';
6
7
  */
7
8
  export declare class Vite {
8
9
  #private;
9
- constructor(options: ViteOptions);
10
+ protected inDev: boolean;
11
+ constructor(inDev: boolean, options: ViteOptions);
10
12
  /**
11
13
  * Generate tags for the entry points
12
14
  */
13
15
  generateEntryPointsTags(entryPoints: string[] | string, attributes?: Record<string, any>): AdonisViteElement[];
14
- /**
15
- * Returns the dev server URL when running in hot
16
- * mode. Otherwise an empty string
17
- */
18
- devUrl(): string;
19
16
  /**
20
17
  * Returns the dev server URL when running in hot
21
18
  * mode, otherwise returns the explicitly configured
22
19
  * "assets" URL
23
20
  */
24
- assetsUrl(): string | undefined;
21
+ assetsUrl(): string | boolean | undefined;
25
22
  /**
26
23
  * Returns path to a given asset file
27
24
  */
@@ -29,9 +26,30 @@ export declare class Vite {
29
26
  /**
30
27
  * Returns the manifest file contents
31
28
  *
32
- * @throws Will throw an exception when running in hot mode
29
+ * @throws Will throw an exception when running in dev
33
30
  */
34
31
  manifest(): Manifest;
32
+ /**
33
+ * Create the Vite Dev Server and runtime
34
+ *
35
+ * We lazy load the APIs to avoid loading it in production
36
+ * since we don't need it
37
+ */
38
+ createDevServer(): Promise<void>;
39
+ /**
40
+ * Stop the Vite Dev server
41
+ */
42
+ stopDevServer(): Promise<void>;
43
+ /**
44
+ * Get the Vite Dev server instance
45
+ * Will not be available when running in production
46
+ */
47
+ getDevServer(): ViteDevServer | undefined;
48
+ /**
49
+ * Get the Vite runtime instance
50
+ * Will not be available when running in production
51
+ */
52
+ getRuntime(): ViteRuntime | undefined;
35
53
  /**
36
54
  * Returns the script needed for the HMR working with React
37
55
  */