Enable "paths" support by default (#11970)

* Enable "paths" support by default

* Enable NEXT_PUBLIC_ prefix exposing the variable globally

Part of #11106
This commit is contained in:
Tim Neutkens 2020-04-17 16:28:17 +02:00 committed by GitHub
parent 26df01800d
commit 511cf748ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 25 deletions

View file

@ -768,17 +768,15 @@ export default async function getBaseWebpackConfig(
// This plugin makes sure `output.filename` is used for entry chunks
new ChunkNamesPlugin(),
new webpack.DefinePlugin({
...(config.experimental.pageEnv
? Object.keys(process.env).reduce(
(prev: { [key: string]: string }, key: string) => {
if (key.startsWith('NEXT_PUBLIC_')) {
prev[`process.env.${key}`] = JSON.stringify(process.env[key]!)
}
return prev
},
{}
)
: {}),
...Object.keys(process.env).reduce(
(prev: { [key: string]: string }, key: string) => {
if (key.startsWith('NEXT_PUBLIC_')) {
prev[`process.env.${key}`] = JSON.stringify(process.env[key]!)
}
return prev
},
{}
),
...Object.keys(config.env).reduce((acc, key) => {
if (/^(?:NODE_.+)|^(?:__.+)$/i.test(key)) {
throw new Error(
@ -1005,11 +1003,7 @@ export default async function getBaseWebpackConfig(
webpackConfig.resolve?.modules?.push(resolvedBaseUrl)
}
if (
config.experimental.jsconfigPaths &&
jsConfig?.compilerOptions?.paths &&
resolvedBaseUrl
) {
if (jsConfig?.compilerOptions?.paths && resolvedBaseUrl) {
webpackConfig.resolve?.plugins?.push(
new JsConfigPathsPlugin(jsConfig.compilerOptions.paths, resolvedBaseUrl)
)

View file

@ -41,7 +41,6 @@ const defaultConfig: { [key: string]: any } = {
(Number(process.env.CIRCLE_NODE_TOTAL) ||
(os.cpus() || { length: 1 }).length) - 1
),
jsconfigPaths: false,
css: true,
scss: true,
documentMiddleware: false,

View file

@ -1,7 +1,5 @@
module.exports = {
experimental: {
pageEnv: true,
async redirects() {
return [
{

View file

@ -1,7 +1,4 @@
module.exports = {
experimental: {
jsconfigPaths: true,
},
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60,

View file

@ -1,7 +1,4 @@
module.exports = {
experimental: {
jsconfigPaths: true,
},
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60,