@@ -279,7 +279,9 @@ const getRouteModuleExports = async (
279
279
const showUnstableWarning = ( ) => {
280
280
console . warn (
281
281
colors . yellow (
282
- "\n ⚠️ Remix support for Vite is unstable\n and not recommended for production\n"
282
+ colors . bold (
283
+ "\n ⚠️ Remix support for Vite is unstable and\n not yet recommended for production\n"
284
+ )
283
285
)
284
286
) ;
285
287
} ;
@@ -295,7 +297,7 @@ export type RemixVitePlugin = (
295
297
export const remixVitePlugin : RemixVitePlugin = ( options = { } ) => {
296
298
let viteCommand : Vite . ResolvedConfig [ "command" ] ;
297
299
let viteUserConfig : Vite . UserConfig ;
298
- let resolvedViteConfig : Vite . ResolvedConfig | undefined ;
300
+ let viteConfig : Vite . ResolvedConfig | undefined ;
299
301
300
302
let isViteV4 = getViteMajorVersion ( ) === 4 ;
301
303
@@ -640,10 +642,10 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
640
642
} ) ,
641
643
} ;
642
644
} ,
643
- async configResolved ( viteConfig ) {
645
+ async configResolved ( resolvedViteConfig ) {
644
646
await initEsModuleLexer ;
645
647
646
- resolvedViteConfig = viteConfig ;
648
+ viteConfig = resolvedViteConfig ;
647
649
648
650
ssrBuildContext =
649
651
viteConfig . build . ssr && viteCommand === "build"
@@ -719,9 +721,38 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
719
721
}
720
722
} ,
721
723
buildStart ( ) {
722
- if ( viteCommand === "build" ) {
724
+ invariant ( viteConfig ) ;
725
+
726
+ if (
727
+ viteCommand === "build" &&
728
+ // Only show warning on initial client build
729
+ ! viteConfig . build . ssr
730
+ ) {
723
731
showUnstableWarning ( ) ;
724
732
}
733
+
734
+ if (
735
+ viteCommand === "build" &&
736
+ viteConfig . mode === "production" &&
737
+ ! viteConfig . build . ssr &&
738
+ viteConfig . build . sourcemap
739
+ ) {
740
+ viteConfig . logger . warn (
741
+ colors . yellow (
742
+ colors . bold ( " ⚠️ Source maps are enabled in production\n" ) +
743
+ [
744
+ "This makes your server code publicly" ,
745
+ "visible in the browser. This is highly" ,
746
+ "discouraged! If you insist, ensure that" ,
747
+ "you are using environment variables for" ,
748
+ "secrets and not hard-coding them in" ,
749
+ "your source code.\n" ,
750
+ ]
751
+ . map ( ( line ) => " " + line )
752
+ . join ( "\n" )
753
+ )
754
+ ) ;
755
+ }
725
756
} ,
726
757
configureServer ( viteDevServer ) {
727
758
viteDevServer . httpServer ?. on ( "listening" , ( ) => {
@@ -814,15 +845,8 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
814
845
return ;
815
846
}
816
847
817
- invariant (
818
- cachedPluginConfig ,
819
- "Expected plugin config to be cached when writeBundle hook is called"
820
- ) ;
821
-
822
- invariant (
823
- resolvedViteConfig ,
824
- "Expected resolvedViteConfig to exist when writeBundle hook is called"
825
- ) ;
848
+ invariant ( cachedPluginConfig ) ;
849
+ invariant ( viteConfig ) ;
826
850
827
851
let { assetsBuildDirectory, serverBuildPath, rootDirectory } =
828
852
cachedPluginConfig ;
@@ -872,10 +896,8 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => {
872
896
)
873
897
) ;
874
898
875
- let logger = resolvedViteConfig . logger ;
876
-
877
899
if ( movedAssetPaths . length ) {
878
- logger . info (
900
+ viteConfig . logger . info (
879
901
[
880
902
"" ,
881
903
`${ colors . green ( "✓" ) } ${ movedAssetPaths . length } asset${
0 commit comments