@trackunit/iris-app-sdk-vite 0.0.3 → 0.0.4
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.
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-sdk-vite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"executors": "./executors.json",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@nx/devkit": "22.0.4",
|
|
12
12
|
"rxjs": "7.8.1",
|
|
13
13
|
"win-ca": "^3.5.1",
|
|
14
|
-
"@trackunit/iris-app-build-utilities": "1.12.
|
|
14
|
+
"@trackunit/iris-app-build-utilities": "1.12.43",
|
|
15
15
|
"@trackunit/iris-app-api": "1.14.39",
|
|
16
16
|
"tslib": "^2.6.2",
|
|
17
17
|
"vite": "7.3.1"
|
|
@@ -29,65 +29,76 @@ async function* serveExecutor(options, context) {
|
|
|
29
29
|
});
|
|
30
30
|
// Now we can safely import the manifest (it uses @trackunit/* imports)
|
|
31
31
|
const IrisAppManifest = (await Promise.resolve(`${manifestPath}`).then(s => tslib_1.__importStar(require(s)))).default;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
32
|
+
const serverlessResult = await (0, iris_app_build_utilities_1.spawnServerlessExtensions)(IrisAppManifest, context.root);
|
|
33
|
+
try {
|
|
34
|
+
// Get default config (internally imports @trackunit/iris-app-vite-plugin)
|
|
35
|
+
const defaultConfig = await (0, defaultViteConfig_1.getDefaultViteConfig)("development", context.root, projectRootDir, IrisAppManifest, context, {
|
|
36
|
+
serverlessPortMap: serverlessResult.portMap,
|
|
37
|
+
});
|
|
38
|
+
// Load optional custom config
|
|
39
|
+
let finalConfig = defaultConfig;
|
|
40
|
+
if (options.viteConfig || (0, fs_1.existsSync)((0, path_1.join)(projectRootDir, "vite.config.ts"))) {
|
|
41
|
+
const customConfigFile = await Promise.resolve(`${options.viteConfig ?? (0, path_1.join)(projectRootDir, "vite.config.ts")}`).then(s => tslib_1.__importStar(require(s)));
|
|
42
|
+
let customConfig = customConfigFile.default(defaultConfig);
|
|
43
|
+
const isPromise = customConfig instanceof Promise;
|
|
44
|
+
if (isPromise) {
|
|
45
|
+
customConfig = await customConfig;
|
|
46
|
+
}
|
|
47
|
+
finalConfig = customConfig;
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// Apply port override if specified
|
|
50
|
+
if (options.port !== undefined) {
|
|
51
|
+
finalConfig.server = { ...finalConfig.server, port: options.port };
|
|
52
|
+
}
|
|
53
|
+
if (options.host) {
|
|
54
|
+
finalConfig.server = { ...finalConfig.server, host: options.host };
|
|
55
|
+
}
|
|
56
|
+
if (context.isVerbose) {
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
58
|
+
console.log("Using Vite config", JSON.stringify(finalConfig.plugins, null, 2));
|
|
59
|
+
}
|
|
60
|
+
// Create and start Vite dev server
|
|
61
|
+
const observable = new rxjs_1.Observable(subscriber => {
|
|
62
|
+
void (async () => {
|
|
63
|
+
try {
|
|
64
|
+
// Dynamic import vite to avoid issues
|
|
65
|
+
const { createServer } = await Promise.resolve().then(() => tslib_1.__importStar(require("vite")));
|
|
66
|
+
const server = await createServer(finalConfig);
|
|
67
|
+
await server.listen();
|
|
68
|
+
const address = server.httpServer?.address();
|
|
69
|
+
const port = typeof address === "object" && address !== null ? address.port : (options.port ?? 22220);
|
|
70
|
+
const host = options.host ?? "localhost";
|
|
71
|
+
const baseUrl = `http://${host}:${port}`;
|
|
72
|
+
server.printUrls();
|
|
73
|
+
subscriber.next({
|
|
74
|
+
baseUrl,
|
|
75
|
+
success: true,
|
|
76
|
+
});
|
|
77
|
+
// Keep alive - server continues running until interrupted
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
// eslint-disable-next-line no-console
|
|
81
|
+
console.error("Vite server error:", error);
|
|
82
|
+
subscriber.error(error);
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
return () => {
|
|
86
|
+
// Cleanup on unsubscribe - handled by Vite's signal handling
|
|
87
|
+
};
|
|
88
|
+
}).pipe(op.tap(({ baseUrl }) => {
|
|
89
|
+
// eslint-disable-next-line no-console
|
|
90
|
+
console.info(`\n 🚀 Iris App dev server running at: ${baseUrl}\n`);
|
|
91
|
+
}), op.map(({ baseUrl, success }) => ({
|
|
92
|
+
baseUrl,
|
|
93
|
+
success,
|
|
94
|
+
})), op.finalize(() => {
|
|
95
|
+
serverlessResult.cleanup();
|
|
96
|
+
}));
|
|
97
|
+
return yield* (0, rxjs_for_await_1.eachValueFrom)(observable);
|
|
51
98
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
99
|
+
catch (error) {
|
|
100
|
+
serverlessResult.cleanup();
|
|
101
|
+
throw error;
|
|
55
102
|
}
|
|
56
|
-
// Create and start Vite dev server
|
|
57
|
-
const observable = new rxjs_1.Observable(subscriber => {
|
|
58
|
-
void (async () => {
|
|
59
|
-
try {
|
|
60
|
-
// Dynamic import vite to avoid issues
|
|
61
|
-
const { createServer } = await Promise.resolve().then(() => tslib_1.__importStar(require("vite")));
|
|
62
|
-
const server = await createServer(finalConfig);
|
|
63
|
-
await server.listen();
|
|
64
|
-
const address = server.httpServer?.address();
|
|
65
|
-
const port = typeof address === "object" && address !== null ? address.port : (options.port ?? 22220);
|
|
66
|
-
const host = options.host ?? "localhost";
|
|
67
|
-
const baseUrl = `http://${host}:${port}`;
|
|
68
|
-
server.printUrls();
|
|
69
|
-
subscriber.next({
|
|
70
|
-
baseUrl,
|
|
71
|
-
success: true,
|
|
72
|
-
});
|
|
73
|
-
// Keep alive - server continues running until interrupted
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
// eslint-disable-next-line no-console
|
|
77
|
-
console.error("Vite server error:", error);
|
|
78
|
-
subscriber.error(error);
|
|
79
|
-
}
|
|
80
|
-
})();
|
|
81
|
-
return () => {
|
|
82
|
-
// Cleanup on unsubscribe - handled by Vite's signal handling
|
|
83
|
-
};
|
|
84
|
-
}).pipe(op.tap(({ baseUrl }) => {
|
|
85
|
-
// eslint-disable-next-line no-console
|
|
86
|
-
console.info(`\n 🚀 Iris App dev server running at: ${baseUrl}\n`);
|
|
87
|
-
}), op.map(({ baseUrl, success }) => ({
|
|
88
|
-
baseUrl,
|
|
89
|
-
success,
|
|
90
|
-
})));
|
|
91
|
-
return yield* (0, rxjs_for_await_1.eachValueFrom)(observable);
|
|
92
103
|
}
|
|
93
104
|
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/vite/src/executors/serve/executor.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/vite/src/executors/serve/executor.ts"],"names":[],"mappings":";;AAwBA,gCA+GC;;AAtID,wEAAoE;AACpE,kFAI6C;AAC7C,2BAAgC;AAChC,+BAA4B;AAC5B,+BAAkC;AAClC,2DAAqC;AACrC,kBAAgB;AAChB,kEAAkE;AAKlE;;;;;;GAMG;AACY,KAAK,SAAS,CAAC,CAAC,aAAa,CAC1C,OAA4B,EAC5B,OAAwB;IAExB,MAAM,IAAA,8CAAmB,EAAC,KAAK,CAAC,CAAC;IAEjC,yGAAyG;IACzG,MAAM,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAA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C;oBAEnB,UAAU,CAAC,IAAI,CAAC;wBACd,OAAO;wBACP,OAAO,EAAE,IAAI;qBACd,CAAC,CAAC;oBAEH,0DAA0D;gBAC5D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,sCAAsC;oBACtC,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;oBAC3C,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC,CAAC,EAAE,CAAC;YAEL,OAAO,GAAG,EAAE;gBACV,6DAA6D;YAC/D,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC,IAAI,CACL,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;YACrB,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,0CAA0C,OAAO,IAAI,CAAC,CAAC;QACtE,CAAC,CAAC,EACF,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;YAChC,OAAO;YACP,OAAO;SACR,CAAC,CAAC,EACH,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE;YACf,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,KAAK,CAAC,CAAC,IAAA,8BAAa,EAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { ExecutorContext } from \"@nx/devkit\";\nimport { eachValueFrom } from \"@nx/devkit/src/utils/rxjs-for-await\";\nimport {\n checkPackageVersion,\n enableTsConfigPath,\n spawnServerlessExtensions,\n} from \"@trackunit/iris-app-build-utilities\";\nimport { existsSync } from \"fs\";\nimport { join } from \"path\";\nimport { Observable } from \"rxjs\";\nimport * as op from \"rxjs/operators\";\nimport \"win-ca\";\nimport { getDefaultViteConfig } from \"../utils/defaultViteConfig\";\nimport { ServeExecutorSchema } from \"./schema\";\n\ntype ServeResult = { baseUrl: string; success: boolean };\n\n/**\n * Serve executor for serving Iris Apps with Vite.\n *\n * @param {ServeExecutorSchema} options serve executor options for this nx executor\n * @param {ExecutorContext} context serve executor context for this nx executor\n * @yields {ServeResult} the serve result\n */\nexport default async function* serveExecutor(\n options: ServeExecutorSchema,\n context: ExecutorContext\n): AsyncGenerator<ServeResult> {\n await checkPackageVersion(false);\n\n // eslint-disable-next-line local-rules/no-typescript-assertion, @typescript-eslint/no-non-null-assertion\n const projectRoot = context.projectsConfigurations.projects[context.projectName!]!.root;\n const projectRootDir = join(context.root, projectRoot);\n const manifestPath = join(context.root, projectRoot, \"iris-app-manifest.ts\");\n\n // ✅ CRITICAL: Register tsconfig paths BEFORE any @trackunit/* imports\n enableTsConfigPath({\n projectRootDir,\n });\n\n // Now we can safely import the manifest (it uses @trackunit/* imports)\n const IrisAppManifest = (await import(manifestPath)).default;\n\n const serverlessResult = await spawnServerlessExtensions(IrisAppManifest, context.root);\n\n try {\n // Get default config (internally imports @trackunit/iris-app-vite-plugin)\n const defaultConfig = await getDefaultViteConfig(\n \"development\",\n context.root,\n projectRootDir,\n IrisAppManifest,\n context,\n {\n serverlessPortMap: serverlessResult.portMap,\n }\n );\n\n // Load optional custom config\n let finalConfig = defaultConfig;\n if (options.viteConfig || existsSync(join(projectRootDir, \"vite.config.ts\"))) {\n const customConfigFile = await import(options.viteConfig ?? join(projectRootDir, \"vite.config.ts\"));\n let customConfig = customConfigFile.default(defaultConfig);\n const isPromise = customConfig instanceof Promise;\n if (isPromise) {\n customConfig = await customConfig;\n }\n finalConfig = customConfig;\n }\n\n // Apply port override if specified\n if (options.port !== undefined) {\n finalConfig.server = { ...finalConfig.server, port: options.port };\n }\n if (options.host) {\n finalConfig.server = { ...finalConfig.server, host: options.host };\n }\n\n if (context.isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"Using Vite config\", JSON.stringify(finalConfig.plugins, null, 2));\n }\n\n // Create and start Vite dev server\n const observable = new Observable<{ baseUrl: string; success: boolean }>(subscriber => {\n void (async () => {\n try {\n // Dynamic import vite to avoid issues\n const { createServer } = await import(\"vite\");\n\n const server = await createServer(finalConfig);\n await server.listen();\n\n const address = server.httpServer?.address();\n const port = typeof address === \"object\" && address !== null ? address.port : (options.port ?? 22220);\n const host = options.host ?? \"localhost\";\n const baseUrl = `http://${host}:${port}`;\n\n server.printUrls();\n\n subscriber.next({\n baseUrl,\n success: true,\n });\n\n // Keep alive - server continues running until interrupted\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Vite server error:\", error);\n subscriber.error(error);\n }\n })();\n\n return () => {\n // Cleanup on unsubscribe - handled by Vite's signal handling\n };\n }).pipe(\n op.tap(({ baseUrl }) => {\n // eslint-disable-next-line no-console\n console.info(`\\n 🚀 Iris App dev server running at: ${baseUrl}\\n`);\n }),\n op.map(({ baseUrl, success }) => ({\n baseUrl,\n success,\n })),\n op.finalize(() => {\n serverlessResult.cleanup();\n })\n );\n\n return yield* eachValueFrom(observable);\n } catch (error) {\n serverlessResult.cleanup();\n throw error;\n }\n}\n"]}
|
|
@@ -52,13 +52,14 @@ const VITE_PLUGIN_PACKAGE = "@trackunit/iris-app-vite-plugin";
|
|
|
52
52
|
* @param context - NX executor context
|
|
53
53
|
* @returns {Promise<UserConfig>} the default Vite config
|
|
54
54
|
*/
|
|
55
|
-
const getDefaultViteConfig = async (mode, nxRootDir, appDir, _irisAppManifest, context) => {
|
|
55
|
+
const getDefaultViteConfig = async (mode, nxRootDir, appDir, _irisAppManifest, context, options = {}) => {
|
|
56
56
|
// Dynamic import - safe after enableTsConfigPath() is called
|
|
57
57
|
const { getTrackunitIrisAppVitePlugins } = await Promise.resolve(`${VITE_PLUGIN_PACKAGE}`).then(s => __importStar(require(s)));
|
|
58
58
|
const irisAppPlugins = await getTrackunitIrisAppVitePlugins({
|
|
59
59
|
appDir,
|
|
60
60
|
workspaceRoot: nxRootDir,
|
|
61
61
|
config: { mode },
|
|
62
|
+
serverlessPortMap: options.serverlessPortMap,
|
|
62
63
|
});
|
|
63
64
|
return {
|
|
64
65
|
root: appDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultViteConfig.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/vite/src/executors/utils/defaultViteConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"defaultViteConfig.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/vite/src/executors/utils/defaultViteConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,+BAA4B;AAG5B,kFAAkF;AAClF,gFAAgF;AAChF,sCAAsC;AACtC,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;AAM9D;;;;;;;;;;;;GAYG;AACI,MAAM,oBAAoB,GAAG,KAAK,EACvC,IAAkC,EAClC,SAAiB,EACjB,MAAc,EACd,gBAAiC,EACjC,OAAwB,EACxB,UAAuC,EAAE,EACpB,EAAE;IACvB,6DAA6D;IAC7D,MAAM,EAAE,8BAA8B,EAAE,GAAG,yBAAa,mBAAmB,uCAAC,CAAC;IAE7E,MAAM,cAAc,GAAG,MAAM,8BAA8B,CAAC;QAC1D,MAAM;QACN,aAAa,EAAE,SAAS;QACxB,MAAM,EAAE,EAAE,IAAI,EAAE;QAChB,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;KAC7C,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI;QACJ,OAAO,EAAE,CAAC,GAAG,cAAc,CAAC;QAC5B,mCAAmC;QACnC,YAAY,EAAE;YACZ,mEAAmE;YACnE,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC;YACpD,6CAA6C;YAC7C,cAAc,EAAE;gBACd,MAAM,EAAE,QAAQ;aACjB;SACF;QACD,KAAK,EAAE;YACL,MAAM,EAAE,aAAa,OAAO,CAAC,WAAW,EAAE;YAC1C,WAAW,EAAE,IAAI;YACjB,+DAA+D;YAC/D,MAAM,EAAE,QAAQ;YAChB,yDAAyD;YACzD,MAAM,EAAE,SAAS;YACjB,sDAAsD;YACtD,SAAS,EAAE,KAAK;YAChB,oCAAoC;YACpC,qBAAqB,EAAE,IAAI;YAC3B,8DAA8D;YAC9D,SAAS,EAAE,EAAE;YACb,2EAA2E;YAC3E,oEAAoE;YACpE,aAAa,EAAE;gBACb,8FAA8F;gBAC9F,KAAK,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,UAAU,CAAC;gBAClC,mEAAmE;gBACnE,MAAM,EAAE;oBACN,mCAAmC;oBACnC,MAAM,EAAE,KAAK;oBACb,6CAA6C;oBAC7C,cAAc,EAAE,WAAW;oBAC3B,mBAAmB;oBACnB,cAAc,EAAE,kBAAkB;oBAClC,gBAAgB;oBAChB,cAAc,EAAE,+BAA+B;iBAChD;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AA/DW,QAAA,oBAAoB,wBA+D/B","sourcesContent":["import { ExecutorContext } from \"@nx/devkit\";\nimport type { IrisAppManifest } from \"@trackunit/iris-app-api\";\nimport type { ServerlessPortMap } from \"@trackunit/iris-app-build-utilities\";\nimport { join } from \"path\";\nimport type { UserConfig } from \"vite\";\n\n// Package name stored in variable to prevent TypeScript from statically analyzing\n// the import path during build. At runtime, enableTsConfigPath() must be called\n// first to register the path mapping.\nconst VITE_PLUGIN_PACKAGE = \"@trackunit/iris-app-vite-plugin\";\n\ntype GetDefaultViteConfigOptions = {\n serverlessPortMap?: ServerlessPortMap;\n};\n\n/**\n * Gets the default Vite config for Iris Apps.\n *\n * IMPORTANT: This function MUST be called AFTER enableTsConfigPath() has been called,\n * because it dynamically imports @trackunit/iris-app-vite-plugin which uses tsconfig paths.\n *\n * @param mode - \"production\" or \"development\"\n * @param nxRootDir - the root of the nx workspace\n * @param appDir - the app directory\n * @param _irisAppManifest - the iris app manifest (used for logging/validation)\n * @param context - NX executor context\n * @returns {Promise<UserConfig>} the default Vite config\n */\nexport const getDefaultViteConfig = async (\n mode: \"production\" | \"development\",\n nxRootDir: string,\n appDir: string,\n _irisAppManifest: IrisAppManifest,\n context: ExecutorContext,\n options: GetDefaultViteConfigOptions = {}\n): Promise<UserConfig> => {\n // Dynamic import - safe after enableTsConfigPath() is called\n const { getTrackunitIrisAppVitePlugins } = await import(VITE_PLUGIN_PACKAGE);\n\n const irisAppPlugins = await getTrackunitIrisAppVitePlugins({\n appDir,\n workspaceRoot: nxRootDir,\n config: { mode },\n serverlessPortMap: options.serverlessPortMap,\n });\n\n return {\n root: appDir,\n mode,\n plugins: [...irisAppPlugins],\n // Optimize dependency pre-bundling\n optimizeDeps: {\n // Force include common dependencies to speed up dev server startup\n include: [\"react\", \"react-dom\", \"react/jsx-runtime\"],\n // Use esbuild for faster dependency scanning\n esbuildOptions: {\n target: \"esnext\",\n },\n },\n build: {\n outDir: `dist/apps/${context.projectName}`,\n emptyOutDir: true,\n // Target modern browsers - faster builds, no legacy transforms\n target: \"esnext\",\n // Use esbuild for minification (MUCH faster than terser)\n minify: \"esbuild\",\n // Disable source maps in production for faster builds\n sourcemap: false,\n // Increase chunk size warning limit\n chunkSizeWarningLimit: 1000,\n // Put remoteEntry.js at root (not in assets/) to match rspack\n assetsDir: \"\",\n // Use JavaScript entry instead of index.html for Module Federation remotes\n // The MF plugin generates remoteEntry.js as the actual bundle entry\n rollupOptions: {\n // this is just a dummy input to make the build pass - as Iris apps are module federation apps\n input: join(__dirname, \"index.ts\"),\n // Preserve the entry file name for Module Federation compatibility\n output: {\n // ESM format for Module Federation\n format: \"esm\",\n // Entry files at root level (same as rspack)\n entryFileNames: \"[name].js\",\n // Chunks with hash\n chunkFileNames: \"[name]-[hash].js\",\n // Static assets\n assetFileNames: \"static/[name]-[hash][extname]\",\n },\n },\n },\n };\n};\n"]}
|