Commit 07af67bf authored by thom's avatar thom Committed by Tim Neutkens

Allow page extensions in any order (#3827)

parent 69b236b9
...@@ -36,7 +36,7 @@ export function createEntry (filePath, {name, pageExtensions} = {}) { ...@@ -36,7 +36,7 @@ export function createEntry (filePath, {name, pageExtensions} = {}) {
// Makes sure supported extensions are stripped off. The outputted file should always be `.js` // Makes sure supported extensions are stripped off. The outputted file should always be `.js`
if (pageExtensions) { if (pageExtensions) {
entryName = entryName.replace(new RegExp(`\\.+(${pageExtensions})`), '.js') entryName = entryName.replace(new RegExp(`\\.+(${pageExtensions})$`), '.js')
} }
return { return {
......
...@@ -28,6 +28,18 @@ describe('createEntry', () => { ...@@ -28,6 +28,18 @@ describe('createEntry', () => {
expect(entry.files[0]).toBe('./pages/index.jsx') expect(entry.files[0]).toBe('./pages/index.jsx')
}) })
it('Should allow custom extension like .tsx to be turned into .js', () => {
const entry = createEntry('pages/index.tsx', {pageExtensions: ['tsx', 'ts'].join('|')})
expect(entry.name).toBe(normalize('bundles/pages/index.js'))
expect(entry.files[0]).toBe('./pages/index.tsx')
})
it('Should allow custom extension like .tsx to be turned into .js with another order', () => {
const entry = createEntry('pages/index.tsx', {pageExtensions: ['ts', 'tsx'].join('|')})
expect(entry.name).toBe(normalize('bundles/pages/index.js'))
expect(entry.files[0]).toBe('./pages/index.tsx')
})
it('Should turn pages/blog/index.js into pages/blog.js', () => { it('Should turn pages/blog/index.js into pages/blog.js', () => {
const entry = createEntry('pages/blog/index.js') const entry = createEntry('pages/blog/index.js')
expect(entry.name).toBe(normalize('bundles/pages/blog.js')) expect(entry.name).toBe(normalize('bundles/pages/blog.js'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment