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
a320dc10
Commit
a320dc10
authored
Apr 24, 2019
by
JJ Kasper
Committed by
Tim Neutkens
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AMP label to AMP only pages in build tree (#7123)
parent
68e41ed3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
index.ts
packages/next/build/index.ts
+10
-1
utils.ts
packages/next/build/utils.ts
+2
-2
next-drop-client-page-plugin.ts
...ext/build/webpack/plugins/next-drop-client-page-plugin.ts
+7
-0
No files found.
packages/next/build/index.ts
View file @
a320dc10
...
@@ -222,7 +222,16 @@ export default async function build(dir: string, conf = null): Promise<void> {
...
@@ -222,7 +222,16 @@ export default async function build(dir: string, conf = null): Promise<void> {
console
.
log
(
chalk
.
green
(
'Compiled successfully.
\
n'
))
console
.
log
(
chalk
.
green
(
'Compiled successfully.
\
n'
))
}
}
printTreeView
(
Object
.
keys
(
mappedPages
))
let
ampPages
=
new
Set
()
if
(
Array
.
isArray
(
configs
[
0
].
plugins
))
{
configs
[
0
].
plugins
.
some
((
plugin
:
any
)
=>
{
if
(
plugin
.
ampPages
)
ampPages
=
plugin
.
ampPages
return
Boolean
(
plugin
.
ampPages
)
})
}
printTreeView
(
Object
.
keys
(
mappedPages
),
ampPages
)
if
(
flyingShuttle
)
{
if
(
flyingShuttle
)
{
await
flyingShuttle
.
save
()
await
flyingShuttle
.
save
()
...
...
packages/next/build/utils.ts
View file @
a320dc10
...
@@ -19,7 +19,7 @@ export function collectPages(
...
@@ -19,7 +19,7 @@ export function collectPages(
)
)
}
}
export
function
printTreeView
(
list
:
string
[])
{
export
function
printTreeView
(
list
:
string
[]
,
ampPages
:
Set
<
string
>
)
{
list
list
.
sort
((
a
,
b
)
=>
(
a
>
b
?
1
:
-
1
))
.
sort
((
a
,
b
)
=>
(
a
>
b
?
1
:
-
1
))
.
forEach
((
item
,
i
)
=>
{
.
forEach
((
item
,
i
)
=>
{
...
@@ -31,7 +31,7 @@ export function printTreeView(list: string[]) {
...
@@ -31,7 +31,7 @@ export function printTreeView(list: string[]) {
:
i
===
list
.
length
-
1
:
i
===
list
.
length
-
1
?
'└'
?
'└'
:
'├'
:
'├'
console
.
log
(
` \x1b[90m
${
corner
}
\x1b[39m
${
item
}
`
)
console
.
log
(
` \x1b[90m
${
corner
}
\x1b[39m
${
item
}
${
ampPages
.
has
(
item
)
?
' (AMP)'
:
''
}
`
)
})
})
console
.
log
()
console
.
log
()
...
...
packages/next/build/webpack/plugins/next-drop-client-page-plugin.ts
View file @
a320dc10
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
extname
}
from
'path'
// Prevents outputting client pages when they are not needed
// Prevents outputting client pages when they are not needed
export
class
DropClientPage
implements
Plugin
{
export
class
DropClientPage
implements
Plugin
{
ampPages
=
new
Set
();
apply
(
compiler
:
Compiler
)
{
apply
(
compiler
:
Compiler
)
{
compiler
.
hooks
.
emit
.
tap
(
'DropClientPage'
,
compilation
=>
{
compiler
.
hooks
.
emit
.
tap
(
'DropClientPage'
,
compilation
=>
{
Object
.
keys
(
compilation
.
assets
).
forEach
(
assetKey
=>
{
Object
.
keys
(
compilation
.
assets
).
forEach
(
assetKey
=>
{
const
asset
=
compilation
.
assets
[
assetKey
]
const
asset
=
compilation
.
assets
[
assetKey
]
if
(
asset
&&
asset
.
_value
&&
asset
.
_value
.
includes
(
'__NEXT_DROP_CLIENT_FILE__'
))
{
if
(
asset
&&
asset
.
_value
&&
asset
.
_value
.
includes
(
'__NEXT_DROP_CLIENT_FILE__'
))
{
const
page
=
'/'
+
assetKey
.
split
(
'pages/'
)[
1
]
const
pageNoExt
=
page
.
split
(
extname
(
page
))[
0
]
this
.
ampPages
.
add
(
pageNoExt
.
replace
(
/
\/
index$/
,
''
)
||
'/'
)
delete
compilation
.
assets
[
assetKey
]
delete
compilation
.
assets
[
assetKey
]
}
}
})
})
...
...
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