chore: reduce modified code

This commit is contained in:
hardfist 2024-07-21 18:20:58 +08:00
parent 1fa178b627
commit 03eba8f996
4 changed files with 45 additions and 46 deletions

View file

@ -1929,9 +1929,9 @@ export default async function getBaseWebpackConfig(
new NextFontManifestPlugin({ new NextFontManifestPlugin({
appDir, appDir,
}), }),
!dev && // !dev &&
isClient && // isClient &&
new CssChunkingPlugin(config.experimental.cssChunking === 'strict'), // new CssChunkingPlugin(config.experimental.cssChunking === 'strict'),
!dev && !dev &&
isClient && isClient &&
new (require('./webpack/plugins/telemetry-plugin').TelemetryPlugin)( new (require('./webpack/plugins/telemetry-plugin').TelemetryPlugin)(

View file

@ -588,47 +588,47 @@ export const css = curry(async function css(
} }
// Enable full mini-css-extract-plugin hmr for prod mode pages or app dir // Enable full mini-css-extract-plugin hmr for prod mode pages or app dir
// if (ctx.isClient && (ctx.isProduction || ctx.hasAppDir)) { if (ctx.isClient && (ctx.isProduction || ctx.hasAppDir)) {
// // Extract CSS as CSS file(s) in the client-side production bundle. // Extract CSS as CSS file(s) in the client-side production bundle.
// const MiniCssExtractPlugin = const MiniCssExtractPlugin =
// require('../../../plugins/mini-css-extract-plugin').default require('@rspack/core').CssExtractRspackPlugin;
// fns.push( fns.push(
// plugin( plugin(
// // @ts-ignore webpack 5 compat // @ts-ignore webpack 5 compat
// new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
// filename: ctx.isProduction filename: ctx.isProduction
// ? 'static/css/[contenthash].css' ? 'static/css/[contenthash].css'
// : 'static/css/[name].css', : 'static/css/[name].css',
// chunkFilename: ctx.isProduction chunkFilename: ctx.isProduction
// ? 'static/css/[contenthash].css' ? 'static/css/[contenthash].css'
// : 'static/css/[name].css', : 'static/css/[name].css',
// // Next.js guarantees that CSS order "doesn't matter", due to imposed // Next.js guarantees that CSS order "doesn't matter", due to imposed
// // restrictions: // restrictions:
// // 1. Global CSS can only be defined in a single entrypoint (_app) // 1. Global CSS can only be defined in a single entrypoint (_app)
// // 2. CSS Modules generate scoped class names by default and cannot // 2. CSS Modules generate scoped class names by default and cannot
// // include Global CSS (:global() selector). // include Global CSS (:global() selector).
// // //
// // While not a perfect guarantee (e.g. liberal use of `:global()` // While not a perfect guarantee (e.g. liberal use of `:global()`
// // selector), this assumption is required to code-split CSS. // selector), this assumption is required to code-split CSS.
// // //
// // If this warning were to trigger, it'd be unactionable by the user, // If this warning were to trigger, it'd be unactionable by the user,
// // but likely not valid -- so we disable it. // but likely not valid -- so we disable it.
// ignoreOrder: true, ignoreOrder: true,
// insert: function (linkTag: HTMLLinkElement) { insert: function (linkTag: HTMLLinkElement) {
// if (typeof _N_E_STYLE_LOAD === 'function') { if (typeof _N_E_STYLE_LOAD === 'function') {
// const { href, onload, onerror } = linkTag const { href, onload, onerror } = linkTag
// _N_E_STYLE_LOAD(new URL(href).pathname).then( _N_E_STYLE_LOAD(new URL(href).pathname).then(
// () => onload?.call(linkTag, { type: 'load' } as Event), () => onload?.call(linkTag, { type: 'load' } as Event),
// () => onerror?.call(linkTag, {} as Event) () => onerror?.call(linkTag, {} as Event)
// ) )
// } else { } else {
// document.head.appendChild(linkTag) document.head.appendChild(linkTag)
// } }
// }, },
// }) })
// ) )
// ) )
// } }
const fn = pipe(...fns) const fn = pipe(...fns)
return fn(config) return fn(config)

View file

@ -33,7 +33,7 @@ export function isCSSMod(mod: {
mod.loaders?.some( mod.loaders?.some(
({ loader }) => ({ loader }) =>
loader.includes('next-style-loader/index.js') || loader.includes('next-style-loader/index.js') ||
// loader.includes('mini-css-extract-plugin/loader.js') || loader.includes('rspack.CssExtractRspackPlugin.loader') ||
loader.includes('@vanilla-extract/webpack-plugin/loader/') loader.includes('@vanilla-extract/webpack-plugin/loader/')
) )
) )

View file

@ -29,7 +29,6 @@ export class CssChunkingPlugin {
} }
public apply(compiler: Compiler) { public apply(compiler: Compiler) {
return
const strict = this.strict const strict = this.strict
const summary = !!process.env.CSS_CHUNKING_SUMMARY const summary = !!process.env.CSS_CHUNKING_SUMMARY
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => { compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {