Skip to content

Commit

Permalink
Fix outputStandalone with optimizeCss (#36028)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Apr 11, 2022
1 parent 8c57979 commit 95a8f31
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/next/build/index.ts
Expand Up @@ -2085,14 +2085,15 @@ export default async function build(
}, []),
]) {
const filePath = path.join(dir, file)
await promises.copyFile(
filePath,
path.join(
distDir,
'standalone',
path.relative(outputFileTracingRoot, filePath)
)
const outputPath = path.join(
distDir,
'standalone',
path.relative(outputFileTracingRoot, filePath)
)
await promises.mkdir(path.dirname(outputPath), {
recursive: true,
})
await promises.copyFile(filePath, outputPath)
}
await recursiveCopy(
path.join(distDir, SERVER_DIRECTORY, 'pages'),
Expand Down
43 changes: 43 additions & 0 deletions test/production/standalone-mode-and-optimizecss/index.test.ts
@@ -0,0 +1,43 @@
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'

describe('standalone mode and optimizeCss', () => {
let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: {
'pages/index.js': `
import styles from './index.module.css'
export default function Page() {
return <p className={styles.home}>hello world</p>
}
`,
'pages/index.module.css': `
.home {
background: orange;
color: black;
}
`,
},
nextConfig: {
experimental: {
optimizeCss: true,
outputStandalone: true,
},
},
dependencies: {
critters: 'latest',
},
})
})
afterAll(() => next.destroy())

it('should work', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('hello world')
expect(html).toContain('background:orange')
})
})

0 comments on commit 95a8f31

Please sign in to comment.