-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09af8e4
commit 0826f8f
Showing
2 changed files
with
41 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 22 additions & 26 deletions
48
javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,42 @@ | ||
package com.javite.spring.config; | ||
|
||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Provides an out-of-the-box configuration for integrating Vite with Spring MVC applications. | ||
* Configuration class for integrating Vite with Spring MVC applications. | ||
* | ||
* <p>This configuration class automatically scans the package {@code io.github.benny123tw.servlet.config} | ||
* for components and provides the necessary beans and properties to enable Vite integration.</p> | ||
* | ||
* <p>The following properties can be configured in the application's {@code application.properties} file:</p> | ||
* <ul> | ||
* <li>{@code vite.debug} - Enables or disables debug mode for Vite integration. Default is {@code true}.</li> | ||
* <li>{@code vite.manifestPath} - Specifies the path to the Vite manifest file. Default is {@code /WEB-INF/dist/.vite/manifest.json}.</li> | ||
* <li>{@code vite.localServerUrl} - Specifies the URL of the local Vite development server. Default is {@code http://localhost:5173}.</li> | ||
* <li>{@code vite.resourcePath} - Specifies the path to Vite resources. Default is {@code /resources}.</li> | ||
* </ul> | ||
* | ||
* <p>Usage example:</p> | ||
* <pre class="code"> | ||
* @Configuration | ||
* @EnableVite | ||
* public class AppConfig { | ||
* // Your other Spring configuration | ||
* } | ||
* </pre> | ||
* | ||
* @see com.javite.spring.annotation.EnableVite | ||
* <p>This class defines beans for Vite properties that can be customized through the application's | ||
* {@code application.properties} file.</p> | ||
*/ | ||
@Configuration | ||
@EnableConfigurationProperties(ViteProperties.class) | ||
public class ViteConfig { | ||
|
||
@Value("${vite.debug:true}") | ||
private boolean debug; | ||
|
||
@Value("${vite.manifestPath:/WEB-INF/dist/.vite/manifest.json}") | ||
private String manifestPath; | ||
|
||
@Value("${vite.localServerUrl:http://localhost:5173}") | ||
private String localServerUrl; | ||
|
||
@Value("${vite.resourcePath:/resources}") | ||
private String resourcePath; | ||
|
||
/** | ||
* Creates a {@link ViteProperties} bean configured with the application's Vite settings. | ||
* | ||
* @return a configured {@link ViteProperties} instance | ||
*/ | ||
@Bean | ||
public ViteProperties viteProperties() { | ||
return new ViteProperties(); | ||
ViteProperties viteProperties = new ViteProperties(); | ||
viteProperties.setDebug(debug); | ||
viteProperties.setManifestPath(manifestPath); | ||
viteProperties.setLocalServerUrl(localServerUrl); | ||
viteProperties.setResourcePath(resourcePath); | ||
return viteProperties; | ||
} | ||
|
||
} |