mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
refactor: rename to serverless and improve struct
This commit is contained in:
parent
904f813ae9
commit
93f265d5e0
@ -7,10 +7,10 @@ import { existsSync, copy, emptyDir } from 'fs-extra'
|
|||||||
import prettyBytes from 'pretty-bytes'
|
import prettyBytes from 'pretty-bytes'
|
||||||
import gzipSize from 'gzip-size'
|
import gzipSize from 'gzip-size'
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
import { getRollupConfig } from './rollup.config'
|
import { getRollupConfig } from './rollup/config'
|
||||||
import { tryImport, hl, prettyPath, compileTemplateToJS, renderTemplate } from './utils'
|
import { tryImport, hl, prettyPath, compileTemplateToJS, renderTemplate } from './utils'
|
||||||
|
|
||||||
async function main () {
|
async function _runCLI () {
|
||||||
const rootDir = resolve(process.cwd(), process.argv[2] || '.')
|
const rootDir = resolve(process.cwd(), process.argv[2] || '.')
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
@ -26,7 +26,7 @@ async function main () {
|
|||||||
logStartup: true
|
logStartup: true
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(config, tryImport(rootDir, './nuxt.config')!.deploy)
|
Object.assign(config, tryImport(rootDir, './nuxt.config')!.serverless)
|
||||||
|
|
||||||
config.buildDir = resolve(config.rootDir, config.buildDir || '.nuxt')
|
config.buildDir = resolve(config.rootDir, config.buildDir || '.nuxt')
|
||||||
|
|
||||||
@ -63,13 +63,19 @@ async function main () {
|
|||||||
|
|
||||||
consola.info(`Generating bundle for ${hl(target.target)}`)
|
consola.info(`Generating bundle for ${hl(target.target)}`)
|
||||||
|
|
||||||
|
const _targetDefaults = tryImport(__dirname, `./targets/${target.target}`) || tryImport(config.rootDir, target.target)
|
||||||
|
if (!_targetDefaults) {
|
||||||
|
consola.warn('Cannot resolve target', target.target)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const _config: any = defu(
|
const _config: any = defu(
|
||||||
// Target specific config by user
|
// Target specific config by user
|
||||||
target,
|
target,
|
||||||
// Global user config
|
// Global user config
|
||||||
config,
|
config,
|
||||||
// Target defaults
|
// Target defaults
|
||||||
tryImport(__dirname, `./targets/${target.target}`) || tryImport(config.rootDir, target.target),
|
_targetDefaults,
|
||||||
// Generic defaults
|
// Generic defaults
|
||||||
{ outDir: resolve(config.buildDir, `dist/${target.target}`), outName: 'index.js' }
|
{ outDir: resolve(config.buildDir, `dist/${target.target}`), outName: 'index.js' }
|
||||||
)
|
)
|
||||||
@ -109,7 +115,9 @@ async function main () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((err) => {
|
export function runCLI () {
|
||||||
|
_runCLI().catch((err) => {
|
||||||
consola.error(err)
|
consola.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
}
|
1
packages/nitro/src/index.ts
Normal file
1
packages/nitro/src/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { runCLI } from './cli'
|
@ -83,10 +83,10 @@ export const getRollupConfig = (config) => {
|
|||||||
const renderer = config.renderer || (config.nuxt === 2 ? 'vue2' : 'vue3')
|
const renderer = config.renderer || (config.nuxt === 2 ? 'vue2' : 'vue3')
|
||||||
options.plugins.push(alias({
|
options.plugins.push(alias({
|
||||||
entries: {
|
entries: {
|
||||||
'~runtime': path.resolve(__dirname, 'runtime'),
|
'~runtime': path.resolve(__dirname, '../runtime'),
|
||||||
'~renderer': require.resolve('./runtime/' + renderer),
|
'~renderer': require.resolve('../runtime/' + renderer),
|
||||||
'~build': config.buildDir,
|
'~build': config.buildDir,
|
||||||
'~mock': require.resolve('./runtime/mock'),
|
'~mock': require.resolve('../runtime/mock'),
|
||||||
...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {})
|
...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
@ -5,7 +5,7 @@ export default {
|
|||||||
dynamicImporter: false,
|
dynamicImporter: false,
|
||||||
hooks: {
|
hooks: {
|
||||||
'done' () {
|
'done' () {
|
||||||
consola.info('Run `vercel deploy` to deploy!')
|
consola.info('Run `vercel serverless` to serverless!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user