Skip to content

Commit a66539c

Browse files
committed
feat: allow setting alias: false to disable default aliases
1 parent ea2b8df commit a66539c

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
@@ -137,15 +137,18 @@ export async function resolveConfig(
137137
defaults: userConfig.webExt ?? userConfig.runner,
138138
});
139139
// Make sure alias are absolute
140-
const alias = Object.fromEntries(
141-
Object.entries({
142-
...mergedConfig.alias,
143-
'@': srcDir,
144-
'~': srcDir,
145-
'@@': root,
146-
'~~': root,
147-
}).map(([key, value]) => [key, path.resolve(root, value)]),
148-
);
140+
const alias =
141+
mergedConfig.alias !== false
142+
? Object.fromEntries(
143+
Object.entries({
144+
...mergedConfig.alias,
145+
'@': srcDir,
146+
'~': srcDir,
147+
'@@': root,
148+
'~~': root,
149+
}).map(([key, value]) => [key, path.resolve(root, value)]),
150+
)
151+
: {};
149152

150153
let devServerConfig: ResolvedConfig['dev']['server'];
151154
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)