Skip to content

Commit

Permalink
fix: resolve chunksDirName based on outNames dirname (vercel)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 14, 2020
1 parent 0caa11e commit e82cfcc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/rollup/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Module from 'module'
import { join, resolve } from 'path'
import { dirname, join, resolve } from 'path'
import { InputOptions, OutputOptions } from 'rollup'
import { terser } from 'rollup-plugin-terser'
import commonjs from '@rollup/plugin-commonjs'
Expand Down Expand Up @@ -88,12 +88,14 @@ export const getRollupConfig = (options: SLSOptions) => {
external.push(...Module.builtinModules)
}

const chunksDirName = join(dirname(options.outName), 'chunks')

const rollupConfig: RollupConfig = {
input: resolvePath(options, options.entry),
output: {
dir: options.targetDir,
entryFileNames: options.outName,
chunkFileNames: 'chunks/_[name].js',
chunkFileNames: join(chunksDirName, '_[name].js'),
inlineDynamicImports: options.inlineChunks,
format: 'cjs',
exports: 'auto',
Expand Down Expand Up @@ -129,7 +131,7 @@ export const getRollupConfig = (options: SLSOptions) => {
rollupConfig.plugins.push(dynamicRequire({
dir: resolve(options.buildDir, 'dist/server'),
inline: options.node === false || options.inlineChunks,
outDir: join(options.targetDir, 'chunks'),
outDir: join(options.targetDir, chunksDirName),
prefix: './',
globbyOptions: {
ignore: [
Expand Down

0 comments on commit e82cfcc

Please sign in to comment.