Skip to content

Commit 75c7072

Browse files
committed
fix: clarifications around studio-ui vite cfg...
fcns previously (incorrectly) named as if they were targeting standalone-ui's cite cfg
1 parent b296872 commit 75c7072

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

packages/cli/src/commands/studio.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,9 @@ async function buildDefaultStudioUI(buildPath: string): Promise<string> {
835835
const studioPackageJsonPath = path.join(buildPath, 'package.json');
836836
await transformPackageJsonForStudioBuild(studioPackageJsonPath);
837837

838-
// Fix Vite config to use npm packages instead of monorepo paths
839-
console.log(chalk.gray(` Updating Vite configuration for standalone build...`));
840-
await fixViteConfigForStandaloneBuild(buildPath);
838+
// Fix Vite config to use npm packages and resolve custom questions imports
839+
console.log(chalk.gray(` Updating Vite configuration for studio build...`));
840+
await createStudioViteConfig(buildPath);
841841

842842
// Run Vite build process
843843
console.log(chalk.gray(` Running Vite build process...`));
@@ -1035,9 +1035,9 @@ async function buildStudioUIWithCustomQuestions(
10351035
const studioPackageJsonPath = path.join(buildPath, 'package.json');
10361036
await transformPackageJsonForStudioBuild(studioPackageJsonPath);
10371037

1038-
// Step 2.5: Fix Vite config to use npm packages instead of monorepo paths
1039-
console.log(chalk.gray(` Updating Vite configuration for standalone build...`));
1040-
await fixViteConfigForStandaloneBuild(buildPath);
1038+
// Step 2.5: Fix Vite config to use npm packages and resolve custom questions imports
1039+
console.log(chalk.gray(` Updating Vite configuration for studio build...`));
1040+
await createStudioViteConfig(buildPath);
10411041

10421042
// Step 3: Install custom questions package
10431043
console.log(
@@ -1258,19 +1258,19 @@ async function runViteBuild(buildPath: string): Promise<void> {
12581258
}
12591259

12601260
/**
1261-
* Fix Vite configuration to work in standalone build environment
1261+
* Create Vite configuration for studio-ui build environment
12621262
*/
1263-
async function fixViteConfigForStandaloneBuild(buildPath: string): Promise<void> {
1263+
async function createStudioViteConfig(buildPath: string): Promise<void> {
12641264
const viteConfigPath = path.join(buildPath, 'vite.config.ts');
12651265

12661266
if (!fs.existsSync(viteConfigPath)) {
12671267
console.log(chalk.yellow(` Warning: vite.config.ts not found at ${viteConfigPath}`));
12681268
return;
12691269
}
12701270

1271-
// Create a clean standalone vite config for external projects
1272-
// Relies on standard npm package resolution instead of monorepo paths
1273-
const standaloneViteConfig = `import { defineConfig } from 'vite';
1271+
// Create a clean studio vite config for studio-ui environment
1272+
// Includes aliases to resolve custom questions imports
1273+
const studioViteConfig = `import { defineConfig } from 'vite';
12741274
import vue from '@vitejs/plugin-vue';
12751275
12761276
export default defineConfig({
@@ -1296,6 +1296,14 @@ export default defineConfig({
12961296
},
12971297
resolve: {
12981298
extensions: ['.js', '.ts', '.json', '.vue'],
1299+
alias: {
1300+
// Resolve @vue-skuilder packages to npm packages for custom questions import
1301+
'@vue-skuilder/common': '@vue-skuilder/common',
1302+
'@vue-skuilder/courseware': '@vue-skuilder/courseware',
1303+
'@vue-skuilder/db': '@vue-skuilder/db',
1304+
'@vue-skuilder/common-ui': '@vue-skuilder/common-ui',
1305+
'@vue-skuilder/edit-ui': '@vue-skuilder/edit-ui'
1306+
},
12991307
dedupe: [
13001308
'vue',
13011309
'vuetify',
@@ -1310,8 +1318,8 @@ export default defineConfig({
13101318
}
13111319
});`;
13121320

1313-
fs.writeFileSync(viteConfigPath, standaloneViteConfig);
1314-
console.log(chalk.gray(` Vite config replaced with standalone version`));
1321+
fs.writeFileSync(viteConfigPath, studioViteConfig);
1322+
console.log(chalk.gray(` Vite config replaced with studio version`));
13151323
}
13161324

13171325
/**

0 commit comments

Comments
 (0)