Skip to content

Commit 891727c

Browse files
jason-changnklayman
authored andcommitted
feat(index): alias '@' to src dir in bundleMain (#487)
* Alias 'src' to '@' path when build main process. Alias 'src' to '@' path when build main process. * fix(tests/commands): check for item in emtpy object * fix(index): remove unnecessary whitespace
1 parent 67c77ee commit 891727c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

__tests__/commands.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe('electron:build', () => {
123123
expect(Object.keys(mainConfig)).not.toContain('module')
124124
// Ts files are not resolved
125125
expect(
126-
mainConfig.resolve ? mainConfig.resolve.extensions : []
126+
mainConfig.resolve.extensions ? mainConfig.resolve.extensions : []
127127
).not.toContain('ts')
128128
// Proper entry file is used
129129
expect(mainConfig.entry.background[0]).toBe('projectPath/src/background.js')
@@ -406,7 +406,7 @@ describe('electron:serve', () => {
406406
expect(Object.keys(mainConfig)).not.toContain('module')
407407
// Ts files are not resolved
408408
expect(
409-
mainConfig.resolve ? mainConfig.resolve.extensions : []
409+
mainConfig.resolve.extensions ? mainConfig.resolve.extensions : []
410410
).not.toContain('ts')
411411
// Proper entry file is used
412412
expect(mainConfig.entry.index[0]).toBe('projectPath/src/background.js')

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,8 @@ function bundleMain ({
575575
additionalFormatters: [formatter]
576576
}
577577
])
578+
config.resolve.alias.set('@', api.resolve('src'))
579+
578580
if (usesTypescript) {
579581
config.resolve.extensions.merge(['.js', '.ts'])
580582
config.module

0 commit comments

Comments
 (0)