Skip to content

Commit 004e4b1

Browse files
committed
feat: allow setting alias: false to disable default aliases
1 parent 71308d0 commit 004e4b1

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

packages/wxt/src/core/resolve-config.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ export async function resolveConfig(
133133
defaults: userConfig.webExt ?? userConfig.runner,
134134
});
135135
// Make sure alias are absolute
136-
const alias = Object.fromEntries(
137-
Object.entries({
138-
...mergedConfig.alias,
139-
'@': srcDir,
140-
'~': srcDir,
141-
'@@': root,
142-
'~~': root,
143-
}).map(([key, value]) => [key, path.resolve(root, value)]),
144-
);
136+
const alias =
137+
mergedConfig.alias !== false
138+
? Object.fromEntries(
139+
Object.entries({
140+
...mergedConfig.alias,
141+
'@': srcDir,
142+
'~': srcDir,
143+
'@@': root,
144+
'~~': root,
145+
}).map(([key, value]) => [key, path.resolve(root, value)]),
146+
)
147+
: {};
145148

146149
let devServerConfig: ResolvedConfig['dev']['server'];
147150
if (command === 'serve') {

packages/wxt/src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,14 @@ export interface InlineConfig {
312312
*
313313
* The key is the import alias and the value is either a relative path to the root directory or an absolute path.
314314
*
315+
* Set to `false` to disable aliases, including the default ones. This is useful if you want to handle aliases in your own plugin. Note that WXT modules can still add aliases.
316+
*
315317
* @example
316318
* {
317319
* "testing": "src/utils/testing.ts"
318320
* }
319321
*/
320-
alias?: Record<string, string>;
322+
alias?: Record<string, string> | false;
321323
/**
322324
* Experimental settings - use with caution.
323325
*/

0 commit comments

Comments
 (0)