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
91f60cda
Unverified
Commit
91f60cda
authored
Jul 29, 2019
by
Joe Haddad
Committed by
GitHub
Jul 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(webpack): extract splitChunksConfig (#8161)
parent
25fd3f86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
36 deletions
+51
-36
webpack-config.ts
packages/next/build/webpack-config.ts
+51
-36
No files found.
packages/next/build/webpack-config.ts
View file @
91f60cda
...
...
@@ -176,6 +176,56 @@ export default async function getBaseWebpackConfig(
const
devtool
=
dev
?
'cheap-module-source-map'
:
false
// Contains various versions of the Webpack SplitChunksPlugin used in different build types
const
splitChunksConfigs
:
{
[
propName
:
string
]:
webpack
.
Options
.
SplitChunksOptions
}
=
{
dev
:
{
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
},
},
selective
:
{
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
react
:
{
name
:
'commons'
,
chunks
:
'all'
,
test
:
/
[\\/]
node_modules
[\\/](
react|react-dom
)[\\/]
/
,
},
},
},
prod
:
{
chunks
:
'all'
,
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
commons
:
{
name
:
'commons'
,
chunks
:
'all'
,
minChunks
:
totalPages
>
2
?
totalPages
*
0.5
:
2
,
},
react
:
{
name
:
'commons'
,
chunks
:
'all'
,
test
:
/
[\\/]
node_modules
[\\/](
react|react-dom
)[\\/]
/
,
},
},
},
}
// Select appropriate SplitChunksPlugin config for this build
let
splitChunksConfig
:
webpack
.
Options
.
SplitChunksOptions
if
(
dev
)
{
splitChunksConfig
=
splitChunksConfigs
.
dev
}
else
if
(
selectivePageBuilding
)
{
splitChunksConfig
=
splitChunksConfigs
.
selective
}
else
{
splitChunksConfig
=
splitChunksConfigs
.
prod
}
const
crossOrigin
=
!
config
.
crossOrigin
&&
config
.
experimental
.
modern
?
'anonymous'
...
...
@@ -278,42 +328,7 @@ export default async function getBaseWebpackConfig(
:
{
name
:
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
,
},
splitChunks
:
dev
?
{
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
},
}
:
selectivePageBuilding
?
{
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
react
:
{
name
:
'commons'
,
chunks
:
'all'
,
test
:
/
[\\/]
node_modules
[\\/](
react|react-dom
)[\\/]
/
,
},
},
}
:
{
chunks
:
'all'
,
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
commons
:
{
name
:
'commons'
,
chunks
:
'all'
,
minChunks
:
totalPages
>
2
?
totalPages
*
0.5
:
2
,
},
react
:
{
name
:
'commons'
,
chunks
:
'all'
,
test
:
/
[\\/]
node_modules
[\\/](
react|react-dom
)[\\/]
/
,
},
},
},
splitChunks
:
splitChunksConfig
,
minimize
:
!
dev
,
minimizer
:
!
dev
?
[
...
...
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