mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
rename default ssr entry to server.js
This commit is contained in:
parent
f2d1064560
commit
274c98f5aa
@ -34,7 +34,7 @@ export function getoptions (nuxtOptions: NuxtOptions): SLSOptions {
|
|||||||
rootDir: nuxtOptions.rootDir,
|
rootDir: nuxtOptions.rootDir,
|
||||||
buildDir: nuxtOptions.buildDir,
|
buildDir: nuxtOptions.buildDir,
|
||||||
publicDir: nuxtOptions.generate.dir,
|
publicDir: nuxtOptions.generate.dir,
|
||||||
outName: 'index.js',
|
outName: 'server.js',
|
||||||
templates: [],
|
templates: [],
|
||||||
static: [],
|
static: [],
|
||||||
nuxt: 2,
|
nuxt: 2,
|
||||||
@ -47,10 +47,10 @@ export function getoptions (nuxtOptions: NuxtOptions): SLSOptions {
|
|||||||
target = target(nuxtOptions)
|
target = target(nuxtOptions)
|
||||||
}
|
}
|
||||||
let targetDefaults = tryImport(LIB_DIR, `./targets/${target}`) || tryImport(nuxtOptions.rootDir, target)
|
let targetDefaults = tryImport(LIB_DIR, `./targets/${target}`) || tryImport(nuxtOptions.rootDir, target)
|
||||||
targetDefaults = targetDefaults.default || targetDefaults
|
|
||||||
if (!targetDefaults) {
|
if (!targetDefaults) {
|
||||||
throw new Error('Cannot resolve target: ' + target)
|
throw new Error('Cannot resolve target: ' + target)
|
||||||
}
|
}
|
||||||
|
targetDefaults = targetDefaults.default || targetDefaults
|
||||||
|
|
||||||
const options: SLSOptions = defu(nuxtOptions.serverless, targetDefaults, defaults, { target })
|
const options: SLSOptions = defu(nuxtOptions.serverless, targetDefaults, defaults, { target })
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import Module from 'module'
|
import Module from 'module'
|
||||||
import path from 'path'
|
import { basename, extname, resolve } from 'path'
|
||||||
import { InputOptions, OutputOptions } from 'rollup'
|
import { InputOptions, OutputOptions } from 'rollup'
|
||||||
import { terser } from 'rollup-plugin-terser'
|
import { terser } from 'rollup-plugin-terser'
|
||||||
import commonjs from '@rollup/plugin-commonjs'
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
import resolve from '@rollup/plugin-node-resolve'
|
import nodeResolve from '@rollup/plugin-node-resolve'
|
||||||
import alias from '@rollup/plugin-alias'
|
import alias from '@rollup/plugin-alias'
|
||||||
import json from '@rollup/plugin-json'
|
import json from '@rollup/plugin-json'
|
||||||
import replace from '@rollup/plugin-replace'
|
import replace from '@rollup/plugin-replace'
|
||||||
@ -52,7 +52,7 @@ export const getRollupConfig = (config: SLSOptions) => {
|
|||||||
const options: RollupConfig = {
|
const options: RollupConfig = {
|
||||||
input: config.entry,
|
input: config.entry,
|
||||||
output: {
|
output: {
|
||||||
file: path.resolve(config.targetDir, config.outName),
|
file: resolve(config.targetDir, config.outName),
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
intro: '',
|
intro: '',
|
||||||
outro: '',
|
outro: '',
|
||||||
@ -78,8 +78,9 @@ export const getRollupConfig = (config: SLSOptions) => {
|
|||||||
|
|
||||||
// Dynamic Require Support
|
// Dynamic Require Support
|
||||||
options.plugins.push(dynamicRequire({
|
options.plugins.push(dynamicRequire({
|
||||||
dir: path.resolve(config.buildDir, 'dist/server'),
|
dir: resolve(config.buildDir, 'dist/server'),
|
||||||
outDir: (config.node === false || config.inlineChunks) ? undefined : config.targetDir,
|
outDir: (config.node === false || config.inlineChunks) ? undefined : config.targetDir,
|
||||||
|
chunksDir: '_' + basename(config.outName, extname(config.outName)),
|
||||||
globbyOptions: {
|
globbyOptions: {
|
||||||
ignore: [
|
ignore: [
|
||||||
'server.js'
|
'server.js'
|
||||||
@ -92,16 +93,16 @@ export const getRollupConfig = (config: SLSOptions) => {
|
|||||||
options.plugins.push(alias({
|
options.plugins.push(alias({
|
||||||
entries: {
|
entries: {
|
||||||
'~runtime': RUNTIME_DIR,
|
'~runtime': RUNTIME_DIR,
|
||||||
'~renderer': require.resolve(path.resolve(RUNTIME_DIR, renderer)),
|
'~renderer': require.resolve(resolve(RUNTIME_DIR, renderer)),
|
||||||
'~build': config.buildDir,
|
'~build': config.buildDir,
|
||||||
'~mock': require.resolve(path.resolve(RUNTIME_DIR, 'mock')),
|
'~mock': require.resolve(resolve(RUNTIME_DIR, 'mock')),
|
||||||
...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {}),
|
...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {}),
|
||||||
...providedDeps.reduce((p, c) => ({ ...p, [c]: require.resolve(c) }), {})
|
...providedDeps.reduce((p, c) => ({ ...p, [c]: require.resolve(c) }), {})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// https://github.com/rollup/plugins/tree/master/packages/node-resolve
|
// https://github.com/rollup/plugins/tree/master/packages/node-resolve
|
||||||
options.plugins.push(resolve({
|
options.plugins.push(nodeResolve({
|
||||||
extensions,
|
extensions,
|
||||||
preferBuiltins: true,
|
preferBuiltins: true,
|
||||||
rootDir: config.rootDir,
|
rootDir: config.rootDir,
|
||||||
|
Loading…
Reference in New Issue
Block a user