File tree Expand file tree Collapse file tree 5 files changed +15
-1
lines changed
vite-base/src/main/kotlin
vite-kotlin/src/main/kotlin Expand file tree Collapse file tree 5 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ fun DumpDsl.dumpViteConfig(config: ViteConfig) {
99
1010 value(" Root" , config.root)
1111 value(" Base" , config.base)
12+ value(" Public dir" , config.publicDir)
1213 }
1314
1415 section(" Build" ) {
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ interface ViteConfig {
3636 root.convention(other.root)
3737 base.convention(other.base)
3838 plugins.convention(other.plugins)
39+ publicDir.convention(other.publicDir)
3940 build.target.convention(other.build.target)
4041 build.modulePreload.convention(other.build.modulePreload)
4142 build.outDir.convention(other.build.outDir)
@@ -149,6 +150,15 @@ interface ViteConfig {
149150 )
150151 }
151152
153+ /* *
154+ * Directory to serve as plain static assets. Files in this directory are served at `/` during dev
155+ * and copied to the root `outDir` during build, and are always served or copied as-is without transform.
156+ *
157+ * The value can be either an absolute file system path or a path relative to the project [root].
158+ */
159+ @get:Internal
160+ val publicDir: Property <String >
161+
152162 /* *
153163 * Configuration for Rollup to build the production bundle.
154164 *
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ abstract class WriteConfig : DefaultTask() {
4242 inputs.property(" plugins" , config.plugins)
4343 inputs.property(" base" , config.base)
4444 inputs.property(" root" , config.root.map { it.toString() })
45+ inputs.property(" publicDir" , config.publicDir.orElse(" false" ))
4546 inputs.property(" build.target" , config.build.target)
4647 inputs.property(" build.modulePreload" , config.build.modulePreload)
4748 inputs.property(" build.outDir" , config.build.outDir.map { it.toString() })
@@ -74,6 +75,7 @@ abstract class WriteConfig : DefaultTask() {
7475 .joinToString(separator = " ,\n " ) { " ${it.exportedAs} (${it.configuration ? : " " } )" }
7576 } ,
7677 ],
78+ publicDir: ${config.publicDir.orNull?.let { " '$it '" } ? : false } ,
7779 build: {
7880 target: '${config.build.target.get()} ',
7981 modulePreload: ${config.build.modulePreload.get()} ,
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ internal val Project.viteBuildProdDir: Provider<Directory>
5454 get() = viteBuildDir.map { it.dir(" prod" ) }
5555
5656internal val Project .viteBuildDevDir: Provider <Directory >
57- get() = viteBuildDir.map { it.dir(" dev/child " ) } // subfolder to match the nesting of the source maps :)
57+ get() = viteBuildDir.map { it.dir(" dev" ) }
5858
5959/* *
6060 * Default dist directory (override by config)
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ internal fun createConfigWriterTasks(project: Project) {
2020
2121 config {
2222 root.set(project.viteBuildDevDir)
23+ publicDir.convention(" ../../../../.." )
2324
2425 build {
2526 outDir.set(project.viteBuildDistDir)
You can’t perform that action at this time.
0 commit comments