提交 07af67bf 编写于 作者: T thom 提交者: Tim Neutkens

Allow page extensions in any order (#3827)

上级 69b236b9
......@@ -36,7 +36,7 @@ export function createEntry (filePath, {name, pageExtensions} = {}) {
// Makes sure supported extensions are stripped off. The outputted file should always be `.js`
if (pageExtensions) {
entryName = entryName.replace(new RegExp(`\\.+(${pageExtensions})`), '.js')
entryName = entryName.replace(new RegExp(`\\.+(${pageExtensions})$`), '.js')
}
return {
......
......@@ -28,6 +28,18 @@ describe('createEntry', () => {
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', () => {
const entry = createEntry('pages/blog/index.js')
expect(entry.name).toBe(normalize('bundles/pages/blog.js'))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册