File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,32 @@ component singleton accessors="true" {
4
4
property name = " buildDirectory" default = " /includes/build" ;
5
5
property name = " manifestFileName" default = " manifest.json" ;
6
6
7
+ /**
8
+ * Gets the assets path based on the entrypoints passed
9
+ *
10
+ * @param entrypoints The entrypoints to get the assets for
11
+ * @return array The asset paths
12
+ */
13
+ function getAssetPaths ( required any entrypoints ) {
14
+ arguments .entrypoints = arrayWrap ( arguments .entrypoints );
15
+ if ( isRunningHot () ) {
16
+ return arguments .entrypoints .map ( ( entrypoint ) = > generateHotAssetPath ( entrypoint ) );
17
+ }
18
+
19
+ var manifest = readManifest ();
20
+ return arguments .entrypoints .map ( ( entrypoint ) = > generateAssetPath ( getEntrypointChunk ( entrypoint ).file ) );
21
+ }
22
+ /**
23
+ * Renders the assets for the entrypoints passed
24
+ *
25
+ * @param entrypoints The entrypoints to get the assets for
26
+ */
7
27
function render ( required any entrypoints ) output = " true" {
8
28
arguments .entrypoints = arrayWrap ( arguments .entrypoints );
9
29
10
30
if ( isRunningHot () ) {
11
31
arrayPrepend ( arguments .entrypoints , " /@vite/client" );
12
- write ( arguments .entrypoints .map ( ( entrypoint ) = > generateTag ( generateHotAssetPath ( entrypoint ) ) ) );
32
+ write ( getAssetPaths ( arguments .entrypoints ) .map ( ( path ) = > generateTag ( path ) ) );
13
33
return ;
14
34
}
15
35
Original file line number Diff line number Diff line change @@ -142,6 +142,27 @@ component extends="tests.resources.ModuleIntegrationSpec" appMapping="/app" {
142
142
}
143
143
}
144
144
} );
145
+
146
+ it ( " can generate an array of asset paths, using custom buildDirectory and manifestFileName parameters" , () = > {
147
+ var customBuildDirectory = " /includes/somewhere-else" ;
148
+ var customManifestFileName = " app-manifest.json" ;
149
+ var customManifestFilePath = expandPath ( " /app#customBuildDirectory #/#customManifestFileName #" );
150
+ try {
151
+ fileWrite ( customManifestFilePath , serializeJSON ( variables .manifestFileContents ) );
152
+ var output = vite ()
153
+ .setBuildDirectory ( customBuildDirectory )
154
+ .setManifestFileName ( customManifestFileName )
155
+ .getAssetPaths ( [ " resources/assets/css/app.css" ] );
156
+
157
+ expect ( output ).toBeTypeOf ( " Array" );
158
+ expect ( output ).toHaveLength ( 1 );
159
+ expect ( output [ 1 ] ).toInclude ( " includes/somewhere-else/assets/app-00d284d6.css" );
160
+ } finally {
161
+ if ( fileExists ( customManifestFilePath ) ) {
162
+ fileDelete ( customManifestFilePath );
163
+ }
164
+ }
165
+ } );
145
166
} );
146
167
} );
147
168
}
You can’t perform that action at this time.
0 commit comments