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