mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Don’t bundle next/asset if it’s not used (#5971)
This commit is contained in:
parent
20fe65ce41
commit
36164ead80
|
@ -1,4 +1,4 @@
|
||||||
let assetPrefix
|
let assetPrefix = typeof window !== 'undefined' ? (window.__NEXT_DATA__.assetPrefix) : undefined
|
||||||
|
|
||||||
export default function asset (path) {
|
export default function asset (path) {
|
||||||
// If the URL starts with http, we assume it's an
|
// If the URL starts with http, we assume it's an
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { createRouter } from 'next/router'
|
||||||
import EventEmitter from 'next-server/dist/lib/event-emitter'
|
import EventEmitter from 'next-server/dist/lib/event-emitter'
|
||||||
import {loadGetInitialProps, getURL} from 'next-server/dist/lib/utils'
|
import {loadGetInitialProps, getURL} from 'next-server/dist/lib/utils'
|
||||||
import PageLoader from './page-loader'
|
import PageLoader from './page-loader'
|
||||||
import * as asset from 'next-server/asset'
|
|
||||||
import * as envConfig from 'next-server/config'
|
import * as envConfig from 'next-server/config'
|
||||||
import ErrorBoundary from './error-boundary'
|
import ErrorBoundary from './error-boundary'
|
||||||
import Loadable from 'next-server/dist/lib/loadable'
|
import Loadable from 'next-server/dist/lib/loadable'
|
||||||
|
@ -38,8 +37,6 @@ const prefix = assetPrefix || ''
|
||||||
// With dynamic assetPrefix it's no longer possible to set assetPrefix at the build time
|
// With dynamic assetPrefix it's no longer possible to set assetPrefix at the build time
|
||||||
// So, this is how we do it in the client side at runtime
|
// So, this is how we do it in the client side at runtime
|
||||||
__webpack_public_path__ = `${prefix}/_next/` //eslint-disable-line
|
__webpack_public_path__ = `${prefix}/_next/` //eslint-disable-line
|
||||||
// Initialize next/asset with the assetPrefix
|
|
||||||
asset.setAssetPrefix(prefix)
|
|
||||||
// Initialize next/config with the environment configuration
|
// Initialize next/config with the environment configuration
|
||||||
envConfig.setConfig({
|
envConfig.setConfig({
|
||||||
serverRuntimeConfig: {},
|
serverRuntimeConfig: {},
|
||||||
|
|
Loading…
Reference in a new issue