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
80f959f6
Unverified
Commit
80f959f6
authored
Nov 03, 2021
by
Tim Neutkens
Committed by
GitHub
Nov 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move browserslist loading webpack-config.ts (#30889)
parent
3c5d5b55
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
18 deletions
+32
-18
webpack-config.ts
packages/next/build/webpack-config.ts
+18
-1
index.ts
packages/next/build/webpack/config/blocks/css/index.ts
+1
-1
overrideCssConfiguration.ts
...ild/webpack/config/blocks/css/overrideCssConfiguration.ts
+5
-2
plugins.ts
packages/next/build/webpack/config/blocks/css/plugins.ts
+4
-14
index.ts
packages/next/build/webpack/config/index.ts
+3
-0
utils.ts
packages/next/build/webpack/config/utils.ts
+1
-0
No files found.
packages/next/build/webpack-config.ts
View file @
80f959f6
...
...
@@ -55,6 +55,21 @@ import { TelemetryPlugin } from './webpack/plugins/telemetry-plugin'
import
type
{
Span
}
from
'../trace'
import
isError
from
'../lib/is-error'
import
{
getRawPageExtensions
}
from
'./utils'
import
browserslist
from
'browserslist'
function
getSupportedBrowsers
(
dir
:
string
,
isDevelopment
:
boolean
):
string
[]
|
undefined
{
let
browsers
:
any
try
{
browsers
=
browserslist
.
loadConfig
({
path
:
dir
,
env
:
isDevelopment
?
'development'
:
'production'
,
})
}
catch
{}
return
browsers
}
type
ExcludesFalse
=
<
T
>
(
x
:
T
|
false
)
=>
x
is
T
...
...
@@ -338,6 +353,7 @@ export default async function getBaseWebpackConfig(
runWebpackSpan
:
Span
}
):
Promise
<
webpack
.
Configuration
>
{
const
supportedBrowsers
=
await
getSupportedBrowsers
(
dir
,
dev
)
const
hasRewrites
=
rewrites
.
beforeFiles
.
length
>
0
||
rewrites
.
afterFiles
.
length
>
0
||
...
...
@@ -1671,6 +1687,7 @@ export default async function getBaseWebpackConfig(
}
webpackConfig
=
await
buildConfiguration
(
webpackConfig
,
{
supportedBrowsers
,
rootDirectory
:
dir
,
customAppFile
:
new
RegExp
(
escapeRegExp
(
path
.
join
(
pagesDir
,
`_app`
))),
isDevelopment
:
dev
,
...
...
@@ -1879,7 +1896,7 @@ export default async function getBaseWebpackConfig(
)
}
}
else
if
(
!
config
.
future
.
strictPostcssConfiguration
)
{
await
__overrideCssConfiguration
(
dir
,
!
dev
,
webpackConfig
)
await
__overrideCssConfiguration
(
dir
,
supportedBrowsers
,
webpackConfig
)
}
// Inject missing React Refresh loaders so that development mode is fast:
...
...
packages/next/build/webpack/config/blocks/css/index.ts
View file @
80f959f6
...
...
@@ -139,7 +139,7 @@ export const css = curry(async function css(
const
postCssPlugins
=
await
getPostCssPlugins
(
ctx
.
rootDirectory
,
ctx
.
isProduction
,
ctx
.
supportedBrowsers
,
!
ctx
.
future
.
strictPostcssConfiguration
)
...
...
packages/next/build/webpack/config/blocks/css/overrideCssConfiguration.ts
View file @
80f959f6
...
...
@@ -4,10 +4,13 @@ import postcss from 'postcss'
export
async
function
__overrideCssConfiguration
(
rootDirectory
:
string
,
isProduction
:
boolean
,
supportedBrowsers
:
string
[]
|
undefined
,
config
:
webpack
.
Configuration
)
{
const
postCssPlugins
=
await
getPostCssPlugins
(
rootDirectory
,
isProduction
)
const
postCssPlugins
=
await
getPostCssPlugins
(
rootDirectory
,
supportedBrowsers
)
function
patch
(
rule
:
webpack
.
RuleSetRule
)
{
if
(
...
...
packages/next/build/webpack/config/blocks/css/plugins.ts
View file @
80f959f6
import
chalk
from
'chalk'
import
{
findConfig
}
from
'../../../../../lib/find-config'
import
browserslist
from
'browserslist'
type
CssPluginCollection_Array
=
(
string
|
[
string
,
boolean
|
object
])[]
...
...
@@ -89,23 +88,14 @@ async function loadPlugin(
}
function
getDefaultPlugins
(
baseDirectory
:
string
,
isProduction
:
boolean
supportedBrowsers
:
string
[]
|
undefined
):
CssPluginCollection
{
let
browsers
:
any
try
{
browsers
=
browserslist
.
loadConfig
({
path
:
baseDirectory
,
env
:
isProduction
?
'production'
:
'development'
,
})
}
catch
{}
return
[
require
.
resolve
(
'next/dist/compiled/postcss-flexbugs-fixes'
),
[
require
.
resolve
(
'next/dist/compiled/postcss-preset-env'
),
{
browsers
:
b
rowsers
??
[
'defaults'
],
browsers
:
supportedB
rowsers
??
[
'defaults'
],
autoprefixer
:
{
// Disable legacy flexbox support
flexbox
:
'no-2009'
,
...
...
@@ -123,7 +113,7 @@ function getDefaultPlugins(
export
async
function
getPostCssPlugins
(
dir
:
string
,
isProduction
:
boolean
,
supportedBrowsers
:
string
[]
|
undefined
,
defaults
:
boolean
=
false
):
Promise
<
import
(
'postcss'
).
AcceptedPlugin
[]
>
{
let
config
=
defaults
...
...
@@ -131,7 +121,7 @@ export async function getPostCssPlugins(
:
await
findConfig
<
{
plugins
:
CssPluginCollection
}
>
(
dir
,
'postcss'
)
if
(
config
==
null
)
{
config
=
{
plugins
:
getDefaultPlugins
(
dir
,
isProduction
)
}
config
=
{
plugins
:
getDefaultPlugins
(
supportedBrowsers
)
}
}
if
(
typeof
config
===
'function'
)
{
...
...
packages/next/build/webpack/config/index.ts
View file @
80f959f6
...
...
@@ -8,6 +8,7 @@ import { ConfigurationContext, pipe } from './utils'
export
async
function
build
(
config
:
webpack
.
Configuration
,
{
supportedBrowsers
,
rootDirectory
,
customAppFile
,
isDevelopment
,
...
...
@@ -21,6 +22,7 @@ export async function build(
experimental
,
disableStaticImages
,
}:
{
supportedBrowsers
:
string
[]
|
undefined
rootDirectory
:
string
customAppFile
:
RegExp
isDevelopment
:
boolean
...
...
@@ -36,6 +38,7 @@ export async function build(
}
):
Promise
<
webpack
.
Configuration
>
{
const
ctx
:
ConfigurationContext
=
{
supportedBrowsers
,
rootDirectory
,
customAppFile
,
isDevelopment
,
...
...
packages/next/build/webpack/config/utils.ts
View file @
80f959f6
...
...
@@ -2,6 +2,7 @@ import { webpack } from 'next/dist/compiled/webpack/webpack'
import
{
NextConfigComplete
}
from
'../../../server/config-shared'
export
type
ConfigurationContext
=
{
supportedBrowsers
:
string
[]
|
undefined
rootDirectory
:
string
customAppFile
:
RegExp
...
...
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