Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
07af67bf
Commit
07af67bf
authored
Feb 17, 2018
by
thom
Committed by
Tim Neutkens
Feb 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow page extensions in any order (#3827)
parent
69b236b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
utils.js
server/build/webpack/utils.js
+1
-1
webpack-utils.test.js
test/isolated/webpack-utils.test.js
+12
-0
No files found.
server/build/webpack/utils.js
View file @
07af67bf
...
...
@@ -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
{
...
...
test/isolated/webpack-utils.test.js
View file @
07af67bf
...
...
@@ -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'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment