Skip to content

Commit

Permalink
Merge branch 'canary' into perf/static-check-avoid-main
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored May 13, 2021
2 parents 843c8c8 + 288984b commit f4f514d
Show file tree
Hide file tree
Showing 25 changed files with 4,659 additions and 996 deletions.
7 changes: 2 additions & 5 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,13 +912,13 @@ export default async function getBaseWebpackConfig(
isServer && isWebpack5 && !dev
? path.join(outputPath, 'chunks')
: outputPath,
// On the server we don't use the chunkhash
// On the server we don't use hashes
filename: isServer
? isWebpack5 && !dev
? '../[name].js'
: '[name].js'
: `static/chunks/${isDevFallback ? 'fallback/' : ''}[name]${
dev ? '' : '-[chunkhash]'
dev ? '' : isWebpack5 ? '-[contenthash]' : '-[chunkhash]'
}.js`,
library: isServer ? undefined : '_N_E',
libraryTarget: isServer ? 'commonjs2' : 'assign',
Expand Down Expand Up @@ -1294,9 +1294,6 @@ export default async function getBaseWebpackConfig(

webpackConfig.cache = cache

// @ts-ignore TODO: remove ignore when webpack 5 is stable
webpackConfig.optimization.realContentHash = false

if (process.env.NEXT_WEBPACK_LOGGING) {
const logInfra = process.env.NEXT_WEBPACK_LOGGING.includes(
'infrastructure'
Expand Down
12 changes: 9 additions & 3 deletions packages/next/build/webpack/config/blocks/css/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import curry from 'next/dist/compiled/lodash.curry'
import path from 'path'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { webpack, isWebpack5 } from 'next/dist/compiled/webpack/webpack'
import MiniCssExtractPlugin from '../../../plugins/mini-css-extract-plugin'
import { loader, plugin } from '../../helpers'
import { ConfigurationContext, ConfigurationFn, pipe } from '../../utils'
Expand All @@ -14,7 +14,7 @@ import {
import { getPostCssPlugins } from './plugins'

// RegExps for all Style Sheet variants
const regexLikeCss = /\.(css|scss|sass)$/
const regexLikeCss = /\.(css|scss|sass)(\.webpack\[javascript\/auto\])?$/

// RegExps for Style Sheets
const regexCssGlobal = /(?<!\.module)\.css$/
Expand Down Expand Up @@ -292,7 +292,12 @@ export const css = curry(async function css(
// This should only be applied to CSS files
issuer: regexLikeCss,
// Exclude extensions that webpack handles by default
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
exclude: [
/\.(js|mjs|jsx|ts|tsx)$/,
/\.html$/,
/\.json$/,
/\.webpack\[[^\]]+\]$/,
],
use: {
// `file-loader` always emits a URL reference, where `url-loader`
// might inline the asset as a data URI
Expand All @@ -314,6 +319,7 @@ export const css = curry(async function css(
plugin(
// @ts-ignore webpack 5 compat
new MiniCssExtractPlugin({
experimentalUseImportModule: isWebpack5,
filename: 'static/css/[contenthash].css',
chunkFilename: 'static/css/[contenthash].css',
// Next.js guarantees that CSS order "doesn't matter", due to imposed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ export function getClientStyleLoader({
: {
// @ts-ignore: TODO: remove when webpack 5 is stable
loader: MiniCssExtractPlugin.loader,
options: { publicPath: `${assetPrefix}/_next/` },
options: { publicPath: `${assetPrefix}/_next/`, esModule: false },
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore: TODO: remove when webpack 5 is stable
import MiniCssExtractPlugin from './mini-css-extract-plugin/src'
import MiniCssExtractPlugin from 'next/dist/compiled/mini-css-extract-plugin'

export default class NextMiniCssExtractPlugin extends MiniCssExtractPlugin {
__next_css_remove = true
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit f4f514d

Please sign in to comment.