{"version":3,"sources":["../../../../../../../src/build/webpack/config/blocks/css/index.ts"],"sourcesContent":["import curry from 'next/dist/compiled/lodash.curry'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { loader, plugin } from '../../helpers'\nimport { pipe } from '../../utils'\nimport type { ConfigurationContext, ConfigurationFn } from '../../utils'\nimport { getCssModuleLoader, getGlobalCssLoader } from './loaders'\nimport { getNextFontLoader } from './loaders/next-font'\nimport {\n  getCustomDocumentError,\n  getGlobalImportError,\n  getGlobalModuleImportError,\n  getLocalModuleImportError,\n} from './messages'\nimport { getPostCssPlugins } from './plugins'\nimport { nonNullable } from '../../../../../lib/non-nullable'\nimport { WEBPACK_LAYERS } from '../../../../../lib/constants'\nimport { getRspackCore } from '../../../../../shared/lib/get-rspack'\n\n// RegExps for all Style Sheet variants\nexport const regexLikeCss = /\\.(css|scss|sass)$/\n\n// RegExps for Style Sheets\nconst regexCssGlobal = /(?<!\\.module)\\.css$/\nconst regexCssModules = /\\.module\\.css$/\n\n// RegExps for Syntactically Awesome Style Sheets\nconst regexSassGlobal = /(?<!\\.module)\\.(scss|sass)$/\nconst regexSassModules = /\\.module\\.(scss|sass)$/\n\nconst APP_LAYER_RULE = {\n  or: [\n    WEBPACK_LAYERS.reactServerComponents,\n    WEBPACK_LAYERS.serverSideRendering,\n    WEBPACK_LAYERS.appPagesBrowser,\n  ],\n}\n\nconst PAGES_LAYER_RULE = {\n  not: [\n    WEBPACK_LAYERS.reactServerComponents,\n    WEBPACK_LAYERS.serverSideRendering,\n    WEBPACK_LAYERS.appPagesBrowser,\n  ],\n}\n\n/**\n * Mark a rule as removable if built-in CSS support is disabled\n */\nfunction markRemovable(r: webpack.RuleSetRule): webpack.RuleSetRule {\n  Object.defineProperty(r, Symbol.for('__next_css_remove'), {\n    enumerable: false,\n    value: true,\n  })\n  return r\n}\n\nlet postcssInstancePromise: Promise<any>\nexport async function lazyPostCSS(\n  rootDirectory: string,\n  supportedBrowsers: string[] | undefined,\n  disablePostcssPresetEnv: boolean | undefined,\n  useLightningcss: boolean | undefined\n) {\n  if (!postcssInstancePromise) {\n    postcssInstancePromise = (async () => {\n      const postcss = require('postcss') as typeof import('postcss')\n      // @ts-ignore backwards compat\n      postcss.plugin = function postcssPlugin(name, initializer) {\n        function creator(...args: any) {\n          let transformer = initializer(...args)\n          transformer.postcssPlugin = name\n          // transformer.postcssVersion = new Processor().version\n          return transformer\n        }\n\n        let cache: any\n        Object.defineProperty(creator, 'postcss', {\n          get() {\n            if (!cache) cache = creator()\n            return cache\n          },\n        })\n\n        creator.process = function (\n          css: any,\n          processOpts: any,\n          pluginOpts: any\n        ) {\n          return postcss([creator(pluginOpts)]).process(css, processOpts)\n        }\n\n        return creator\n      }\n\n      // @ts-ignore backwards compat\n      postcss.vendor = {\n        /**\n         * Returns the vendor prefix extracted from an input string.\n         *\n         * @example\n         * postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'\n         * postcss.vendor.prefix('tab-size')      //=> ''\n         */\n        prefix: function prefix(prop: string): string {\n          const match = prop.match(/^(-\\w+-)/)\n\n          if (match) {\n            return match[0]\n          }\n\n          return ''\n        },\n\n        /**\n         * Returns the input string stripped of its vendor prefix.\n         *\n         * @example\n         * postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'\n         */\n        unprefixed: function unprefixed(\n          /**\n           * String with or without vendor prefix.\n           */\n          prop: string\n        ): string {\n          return prop.replace(/^-\\w+-/, '')\n        },\n      }\n\n      const postCssPlugins = await getPostCssPlugins(\n        rootDirectory,\n        supportedBrowsers,\n        disablePostcssPresetEnv,\n        useLightningcss\n      )\n\n      return {\n        postcss,\n        postcssWithPlugins: postcss(postCssPlugins),\n      }\n    })()\n  }\n\n  return postcssInstancePromise\n}\n\nexport const css = curry(async function css(\n  ctx: ConfigurationContext,\n  config: webpack.Configuration\n) {\n  const isRspack = Boolean(process.env.NEXT_RSPACK)\n  const {\n    prependData: sassPrependData,\n    additionalData: sassAdditionalData,\n    implementation: sassImplementation,\n    ...sassOptions\n  } = ctx.sassOptions\n\n  const lazyPostCSSInitializer = () =>\n    lazyPostCSS(\n      ctx.rootDirectory,\n      ctx.supportedBrowsers,\n      ctx.experimental.disablePostcssPresetEnv,\n      ctx.experimental.useLightningcss\n    )\n\n  const sassPreprocessors: webpack.RuleSetUseItem[] = [\n    // First, process files with `sass-loader`: this inlines content, and\n    // compiles away the proprietary syntax.\n    {\n      loader: require.resolve('next/dist/compiled/sass-loader'),\n      options: {\n        implementation: sassImplementation,\n        // Source maps are required so that `resolve-url-loader` can locate\n        // files original to their source directory.\n        sourceMap: true,\n        sassOptions,\n        additionalData: sassPrependData || sassAdditionalData,\n      },\n    },\n    // Then, `sass-loader` will have passed-through CSS imports as-is instead\n    // of inlining them. Because they were inlined, the paths are no longer\n    // correct.\n    // To fix this, we use `resolve-url-loader` to rewrite the CSS\n    // imports to real file paths.\n    {\n      loader: require.resolve('../../../loaders/resolve-url-loader/index'),\n      options: {\n        postcss: lazyPostCSSInitializer,\n        // Source maps are not required here, but we may as well emit\n        // them.\n        sourceMap: true,\n      },\n    },\n  ]\n\n  const fns: ConfigurationFn[] = []\n\n  const googleLoader = require.resolve(\n    'next/dist/compiled/@next/font/google/loader'\n  )\n  const localLoader = require.resolve(\n    'next/dist/compiled/@next/font/local/loader'\n  )\n  const nextFontLoaders: Array<[string | RegExp, string, any?]> = [\n    [require.resolve('next/font/google/target.css'), googleLoader],\n    [require.resolve('next/font/local/target.css'), localLoader],\n  ]\n\n  nextFontLoaders.forEach(([fontLoaderTarget, fontLoaderPath]) => {\n    // Matches the resolved font loaders noop files to run next-font-loader\n    fns.push(\n      loader({\n        oneOf: [\n          markRemovable({\n            sideEffects: false,\n            test: fontLoaderTarget,\n            use: getNextFontLoader(ctx, lazyPostCSSInitializer, fontLoaderPath),\n          }),\n        ],\n      })\n    )\n  })\n\n  // CSS cannot be imported in _document. This comes before everything because\n  // global CSS nor CSS modules work in said file.\n  fns.push(\n    loader({\n      oneOf: [\n        markRemovable({\n          test: regexLikeCss,\n          // Use a loose regex so we don't have to crawl the file system to\n          // find the real file name (if present).\n          issuer: /pages[\\\\/]_document\\./,\n          use: {\n            loader: 'error-loader',\n            options: {\n              reason: getCustomDocumentError(),\n            },\n          },\n        }),\n      ],\n    })\n  )\n\n  const shouldIncludeExternalCSSImports =\n    !!ctx.experimental.craCompat || !!ctx.transpilePackages\n\n  // CSS modules & SASS modules support. They are allowed to be imported in anywhere.\n  fns.push(\n    // CSS Modules should never have side effects. This setting will\n    // allow unused CSS to be removed from the production build.\n    // We ensure this by disallowing `:global()` CSS at the top-level\n    // via the `pure` mode in `css-loader`.\n    loader({\n      oneOf: [\n        // For app dir, we need to match the specific app layer.\n        ctx.hasAppDir\n          ? markRemovable({\n              sideEffects: true,\n              test: regexCssModules,\n              issuerLayer: APP_LAYER_RULE,\n              use: [\n                {\n                  loader: require.resolve(\n                    '../../../loaders/next-flight-css-loader'\n                  ),\n                  options: {\n                    cssModules: true,\n                  },\n                },\n                ...getCssModuleLoader(\n                  { ...ctx, isAppDir: true },\n                  lazyPostCSSInitializer\n                ),\n              ],\n            })\n          : null,\n        markRemovable({\n          sideEffects: true,\n          test: regexCssModules,\n          issuerLayer: PAGES_LAYER_RULE,\n          use: getCssModuleLoader(\n            { ...ctx, isAppDir: false },\n            lazyPostCSSInitializer\n          ),\n        }),\n      ].filter(nonNullable),\n    }),\n    // Opt-in support for Sass (using .scss or .sass extensions).\n    // Sass Modules should never have side effects. This setting will\n    // allow unused Sass to be removed from the production build.\n    // We ensure this by disallowing `:global()` Sass at the top-level\n    // via the `pure` mode in `css-loader`.\n    loader({\n      oneOf: [\n        // For app dir, we need to match the specific app layer.\n        ctx.hasAppDir\n          ? markRemovable({\n              sideEffects: true,\n              test: regexSassModules,\n              issuerLayer: APP_LAYER_RULE,\n              use: [\n                {\n                  loader: require.resolve(\n                    '../../../loaders/next-flight-css-loader'\n                  ),\n                  options: {\n                    cssModules: true,\n                  },\n                },\n                ...getCssModuleLoader(\n                  { ...ctx, isAppDir: true },\n                  lazyPostCSSInitializer,\n                  sassPreprocessors\n                ),\n              ],\n            })\n          : null,\n        markRemovable({\n          sideEffects: true,\n          test: regexSassModules,\n          issuerLayer: PAGES_LAYER_RULE,\n          use: getCssModuleLoader(\n            { ...ctx, isAppDir: false },\n            lazyPostCSSInitializer,\n            sassPreprocessors\n          ),\n        }),\n      ].filter(nonNullable),\n    }),\n    // Throw an error for CSS Modules used outside their supported scope\n    loader({\n      oneOf: [\n        markRemovable({\n          test: [regexCssModules, regexSassModules],\n          use: {\n            loader: 'error-loader',\n            options: {\n              reason: getLocalModuleImportError(),\n            },\n          },\n        }),\n      ],\n    })\n  )\n\n  // Global CSS and SASS support.\n  if (ctx.isServer) {\n    fns.push(\n      loader({\n        oneOf: [\n          ctx.hasAppDir && !ctx.isProduction\n            ? markRemovable({\n                sideEffects: true,\n                test: [regexCssGlobal, regexSassGlobal],\n                issuerLayer: APP_LAYER_RULE,\n                use: {\n                  loader: require.resolve(\n                    '../../../loaders/next-flight-css-loader'\n                  ),\n                  options: {\n                    cssModules: false,\n                  },\n                },\n              })\n            : null,\n          markRemovable({\n            // CSS imports have side effects, even on the server side.\n            sideEffects: true,\n            test: [regexCssGlobal, regexSassGlobal],\n            use: require.resolve('next/dist/compiled/ignore-loader'),\n          }),\n        ].filter(nonNullable),\n      })\n    )\n  } else {\n    // External CSS files are allowed to be loaded when any of the following is true:\n    // - hasAppDir: all CSS files are allowed\n    // - If the CSS file is located in `node_modules`\n    // - If the CSS file is located in another package in a monorepo (outside of the current rootDir)\n    // - If the issuer is pages/_app (matched later)\n    const allowedPagesGlobalCSSPath = ctx.hasAppDir\n      ? undefined\n      : {\n          and: [\n            {\n              or: [\n                /node_modules/,\n                {\n                  not: [ctx.rootDirectory],\n                },\n              ],\n            },\n          ],\n        }\n    const allowedPagesGlobalCSSIssuer = ctx.hasAppDir\n      ? undefined\n      : shouldIncludeExternalCSSImports\n        ? undefined\n        : {\n            and: [ctx.rootDirectory],\n            not: [/node_modules/],\n          }\n\n    fns.push(\n      loader({\n        oneOf: [\n          ...(ctx.hasAppDir\n            ? [\n                markRemovable({\n                  sideEffects: true,\n                  test: regexCssGlobal,\n                  issuerLayer: APP_LAYER_RULE,\n                  use: [\n                    {\n                      loader: require.resolve(\n                        '../../../loaders/next-flight-css-loader'\n                      ),\n                      options: {\n                        cssModules: false,\n                      },\n                    },\n                    ...getGlobalCssLoader(\n                      { ...ctx, isAppDir: true },\n                      lazyPostCSSInitializer\n                    ),\n                  ],\n                }),\n                markRemovable({\n                  sideEffects: true,\n                  test: regexSassGlobal,\n                  issuerLayer: APP_LAYER_RULE,\n                  use: [\n                    {\n                      loader: require.resolve(\n                        '../../../loaders/next-flight-css-loader'\n                      ),\n                      options: {\n                        cssModules: false,\n                      },\n                    },\n                    ...getGlobalCssLoader(\n                      { ...ctx, isAppDir: true },\n                      lazyPostCSSInitializer,\n                      sassPreprocessors\n                    ),\n                  ],\n                }),\n              ]\n            : []),\n          markRemovable({\n            sideEffects: true,\n            test: regexCssGlobal,\n            include: allowedPagesGlobalCSSPath,\n            issuer: allowedPagesGlobalCSSIssuer,\n            issuerLayer: PAGES_LAYER_RULE,\n            use: getGlobalCssLoader(\n              { ...ctx, isAppDir: false },\n              lazyPostCSSInitializer\n            ),\n          }),\n          markRemovable({\n            sideEffects: true,\n            test: regexSassGlobal,\n            include: allowedPagesGlobalCSSPath,\n            issuer: allowedPagesGlobalCSSIssuer,\n            issuerLayer: PAGES_LAYER_RULE,\n            use: getGlobalCssLoader(\n              { ...ctx, isAppDir: false },\n              lazyPostCSSInitializer,\n              sassPreprocessors\n            ),\n          }),\n        ].filter(nonNullable),\n      })\n    )\n\n    if (ctx.customAppFile) {\n      fns.push(\n        loader({\n          oneOf: [\n            markRemovable({\n              sideEffects: true,\n              test: regexCssGlobal,\n              issuer: { and: [ctx.customAppFile] },\n              use: getGlobalCssLoader(\n                { ...ctx, isAppDir: false },\n                lazyPostCSSInitializer\n              ),\n            }),\n          ],\n        }),\n        loader({\n          oneOf: [\n            markRemovable({\n              sideEffects: true,\n              test: regexSassGlobal,\n              issuer: { and: [ctx.customAppFile] },\n              use: getGlobalCssLoader(\n                { ...ctx, isAppDir: false },\n                lazyPostCSSInitializer,\n                sassPreprocessors\n              ),\n            }),\n          ],\n        })\n      )\n    }\n  }\n\n  // Throw an error for Global CSS used inside of `node_modules`\n  if (!shouldIncludeExternalCSSImports) {\n    fns.push(\n      loader({\n        oneOf: [\n          markRemovable({\n            test: [regexCssGlobal, regexSassGlobal],\n            issuer: { and: [/node_modules/] },\n            use: {\n              loader: 'error-loader',\n              options: {\n                reason: getGlobalModuleImportError(),\n              },\n            },\n          }),\n        ],\n      })\n    )\n  }\n\n  // Throw an error for Global CSS used outside of our custom <App> file\n  fns.push(\n    loader({\n      oneOf: [\n        markRemovable({\n          test: [regexCssGlobal, regexSassGlobal],\n          issuer: ctx.hasAppDir\n            ? {\n                // If it's inside the app dir, but not importing from a layout file,\n                // throw an error.\n                and: [ctx.rootDirectory],\n                not: [/layout\\.(js|mjs|jsx|ts|tsx)$/],\n              }\n            : undefined,\n          use: {\n            loader: 'error-loader',\n            options: {\n              reason: getGlobalImportError(),\n            },\n          },\n        }),\n      ],\n    })\n  )\n\n  if (ctx.isClient) {\n    // Automatically transform references to files (i.e. url()) into URLs\n    // e.g. url(./logo.svg)\n    fns.push(\n      loader({\n        oneOf: [\n          markRemovable({\n            // This should only be applied to CSS files\n            issuer: regexLikeCss,\n            // Exclude extensions that webpack handles by default\n            exclude: [\n              /\\.(js|mjs|jsx|ts|tsx)$/,\n              /\\.html$/,\n              /\\.json$/,\n              /\\.webpack\\[[^\\]]+\\]$/,\n            ],\n            // `asset/resource` always emits a URL reference, where `asset`\n            // might inline the asset as a data URI\n            type: 'asset/resource',\n          }),\n        ],\n      })\n    )\n  }\n\n  // Enable full mini-css-extract-plugin hmr for prod mode pages or app dir\n  if (ctx.isClient && (ctx.isProduction || ctx.hasAppDir)) {\n    // Extract CSS as CSS file(s) in the client-side production bundle.\n    const MiniCssExtractPlugin = isRspack\n      ? getRspackCore().CssExtractRspackPlugin\n      : (\n          require('../../../plugins/mini-css-extract-plugin') as typeof import('../../../plugins/mini-css-extract-plugin')\n        ).default\n\n    fns.push(\n      plugin(\n        // @ts-ignore webpack 5 compat\n        new MiniCssExtractPlugin({\n          filename: ctx.isProduction\n            ? 'static/css/[contenthash].css'\n            : 'static/css/[name].css',\n          chunkFilename: ctx.isProduction\n            ? 'static/css/[contenthash].css'\n            : 'static/css/[name].css',\n          // Next.js guarantees that CSS order \"doesn't matter\", due to imposed\n          // restrictions:\n          // 1. Global CSS can only be defined in a single entrypoint (_app)\n          // 2. CSS Modules generate scoped class names by default and cannot\n          //    include Global CSS (:global() selector).\n          //\n          // While not a perfect guarantee (e.g. liberal use of `:global()`\n          // selector), this assumption is required to code-split CSS.\n          //\n          // If this warning were to trigger, it'd be unactionable by the user,\n          // but likely not valid -- so we disable it.\n          ignoreOrder: true,\n          insert: function (linkTag: HTMLLinkElement) {\n            if (typeof _N_E_STYLE_LOAD === 'function') {\n              // Avoid destructuring and optional-chaining here: this function\n              // is serialized as a string by mini-css-extract-plugin and\n              // injected directly into the browser bundle without further\n              // transpilation. Destructuring (`const { x } = obj`) breaks on\n              // browsers that pre-date ES2015 support (e.g. Chrome <49).\n              var href = linkTag.href\n              var onload = linkTag.onload\n              var onerror = linkTag.onerror\n              _N_E_STYLE_LOAD(\n                href.indexOf(window.location.origin) === 0\n                  ? new URL(href).pathname\n                  : href\n              ).then(\n                function () {\n                  if (onload) onload.call(linkTag, { type: 'load' } as Event)\n                },\n                function () {\n                  if (onerror) onerror.call(linkTag, {} as Event)\n                }\n              )\n            } else {\n              document.head.appendChild(linkTag)\n            }\n          },\n        })\n      )\n    )\n  }\n\n  const fn = pipe(...fns)\n  return fn(config)\n})\n"],"names":["curry","loader","plugin","pipe","getCssModuleLoader","getGlobalCssLoader","getNextFontLoader","getCustomDocumentError","getGlobalImportError","getGlobalModuleImportError","getLocalModuleImportError","getPostCssPlugins","nonNullable","WEBPACK_LAYERS","getRspackCore","regexLikeCss","regexCssGlobal","regexCssModules","regexSassGlobal","regexSassModules","APP_LAYER_RULE","or","reactServerComponents","serverSideRendering","appPagesBrowser","PAGES_LAYER_RULE","not","markRemovable","r","Object","defineProperty","Symbol","for","enumerable","value","postcssInstancePromise","lazyPostCSS","rootDirectory","supportedBrowsers","disablePostcssPresetEnv","useLightningcss","postcss","require","postcssPlugin","name","initializer","creator","args","transformer","cache","get","process","css","processOpts","pluginOpts","vendor","prefix","prop","match","unprefixed","replace","postCssPlugins","postcssWithPlugins","ctx","config","isRspack","Boolean","env","NEXT_RSPACK","prependData","sassPrependData","additionalData","sassAdditionalData","implementation","sassImplementation","sassOptions","lazyPostCSSInitializer","experimental","sassPreprocessors","resolve","options","sourceMap","fns","googleLoader","localLoader","nextFontLoaders","forEach","fontLoaderTarget","fontLoaderPath","push","oneOf","sideEffects","test","use","issuer","reason","shouldIncludeExternalCSSImports","craCompat","transpilePackages","hasAppDir","issuerLayer","cssModules","isAppDir","filter","isServer","isProduction","allowedPagesGlobalCSSPath","undefined","and","allowedPagesGlobalCSSIssuer","include","customAppFile","isClient","exclude","type","MiniCssExtractPlugin","CssExtractRspackPlugin","default","filename","chunkFilename","ignoreOrder","insert","linkTag","_N_E_STYLE_LOAD","href","onload","onerror","indexOf","window","location","origin","URL","pathname","then","call","document","head","appendChild","fn"],"mappings":"AAAA,OAAOA,WAAW,kCAAiC;AAEnD,SAASC,MAAM,EAAEC,MAAM,QAAQ,gBAAe;AAC9C,SAASC,IAAI,QAAQ,cAAa;AAElC,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,YAAW;AAClE,SAASC,iBAAiB,QAAQ,sBAAqB;AACvD,SACEC,sBAAsB,EACtBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,yBAAyB,QACpB,aAAY;AACnB,SAASC,iBAAiB,QAAQ,YAAW;AAC7C,SAASC,WAAW,QAAQ,kCAAiC;A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