Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(webpack): chunk name normalization for catch-all pages and windows #7603

Merged
merged 4 commits into from Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/utils/src/resolve.js
Expand Up @@ -18,10 +18,9 @@ export const wp = function wp (p = '') {
}

export const wChunk = function wChunk (p = '') {
if (isWindows) {
return p.replace(/\//g, '_')
}
return p
// workaround for SplitChunksPlugin that generate names starting from . for catchAll pages _.vue
// consider using https://webpack.js.org/configuration/output/#outputfilename for more robust control over filename generation
return p.replace('_', '[_]')
}

const reqSep = /\//g
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/test/resolve.win.test.js
Expand Up @@ -12,7 +12,7 @@ describe.win('util: resolve windows', () => {
})

test('should format windows path', () => {
expect(wChunk('nuxt/layout/test')).toEqual('nuxt_layout_test')
expect(wChunk('nuxt/layout/test')).toEqual('nuxt/layout/test')
})

test('should resolve alias path', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/dev/extract-css.test.js
Expand Up @@ -5,7 +5,6 @@ import { loadFixture, getPort, Nuxt } from '../utils'

let nuxt = null
const readFile = promisify(fs.readFile)
const isWindows = process.platform.startsWith('win')

describe('extract css', () => {
beforeAll(async () => {
Expand All @@ -17,7 +16,7 @@ describe('extract css', () => {
})

test('Verify global.css has been extracted and minified', async () => {
const fileName = isWindows ? 'pages_index.css' : 'pages/index.css'
const fileName = 'pages/index.css'
const extractedIndexCss = resolve(__dirname, '..', 'fixtures/extract-css/.nuxt/dist/client', fileName)
const content = await readFile(extractedIndexCss, 'utf-8')

Expand Down