Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): allow to set custom root directory #5446

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/config/load-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const loadConfig = async (init: LoadConfigInit = {}): Promise<LoadConfigR
configPath = loadedConfigFile.configPath;
unknownConfig.config = { ...loadedConfigFile, ...config };
unknownConfig.config.configPath = configPath;
unknownConfig.config.rootDir = normalizePath(dirname(configPath));
unknownConfig.config.rootDir = config.rootDir || normalizePath(dirname(configPath));
} else {
// no stencil.config.ts or .js file, which is fine
unknownConfig.config = { ...config };
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/config/test/load-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('load config', () => {
sys,
config: {
hashedFileNameLength: 9,
rootDir: '/foo/bar',
},
initTsConfig: true,
});
Expand All @@ -50,6 +51,8 @@ describe('load config', () => {
expect<ConfigFlags>(actualConfig.flags).toEqual({ dev: true });
expect(actualConfig.extras).toBeDefined();
expect(actualConfig.extras!.enableImportInjection).toBe(true);
// respects custom root dir
expect(actualConfig.rootDir).toBe('/foo/bar');
});

it('uses the provided config path when no initial config provided', async () => {
Expand Down
Loading