Skip to content

Commit

Permalink
fix(options): add default aliases and resolve plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 8, 2022
1 parent 0d1cd4d commit f04560b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'pathe'
import { resolve, join } from 'pathe'
import { loadConfig } from 'c12'
import { klona } from 'klona/full'
import { camelCase } from 'scule'
Expand Down Expand Up @@ -121,6 +121,15 @@ export async function loadOptions (userConfig: NitroConfig = {}): Promise<NitroO
options[key] = resolve(options.rootDir, options[key])
}

// Add aliases
options.alias = {
...options.alias,
'~/': join(options.srcDir, '/'),
'@/': join(options.srcDir, '/'),
'~~/': join(options.rootDir, '/'),
'@@/': join(options.rootDir, '/')
}

// Resolve possibly template paths
if (!options.entry) {
throw new Error(`Nitro entry is missing! Is "${options.preset}" preset correct?`)
Expand Down Expand Up @@ -193,6 +202,9 @@ export async function loadOptions (userConfig: NitroConfig = {}): Promise<NitroO
options.devStorage[p] = options.devStorage[p] || { driver: 'fs', base: fsMounts[p] }
}

// Resolve plugin paths
options.plugins = options.plugins.map(p => resolvePath(p, options))

return options
}

Expand Down

0 comments on commit f04560b

Please sign in to comment.