This commit is contained in:
Kismet Hasanaj
2026-05-02 20:07:02 +02:00
parent ce8672e283
commit 34dc9aec52
9428 changed files with 1733330 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { ConfigurationContext } from '../utils';
export declare const base: import("lodash").CurriedFunction2<ConfigurationContext, webpack.Configuration, webpack.Configuration>;
+82
View File
@@ -0,0 +1,82 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "base", {
enumerable: true,
get: function() {
return base;
}
});
const _lodashcurry = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/lodash.curry"));
const _constants = require("../../../../shared/lib/constants");
const _devtoolsignorelistplugin = /*#__PURE__*/ _interop_require_default(require("../../plugins/devtools-ignore-list-plugin"));
const _evalsourcemapdevtoolplugin = /*#__PURE__*/ _interop_require_default(require("../../plugins/eval-source-map-dev-tool-plugin"));
const _getrspack = require("../../../../shared/lib/get-rspack");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function shouldIgnorePath(modulePath) {
return modulePath.includes('node_modules') || modulePath.endsWith('__nextjs-internal-proxy.cjs') || modulePath.endsWith('__nextjs-internal-proxy.mjs') || // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo
modulePath.includes('next/dist');
}
const base = (0, _lodashcurry.default)(function base(ctx, config) {
config.mode = ctx.isDevelopment ? 'development' : 'production';
config.name = ctx.isServer ? ctx.isEdgeRuntime ? _constants.COMPILER_NAMES.edgeServer : _constants.COMPILER_NAMES.server : _constants.COMPILER_NAMES.client;
config.target = !ctx.targetWeb ? 'node18.17' // Same version defined in packages/next/package.json#engines
: ctx.isEdgeRuntime ? [
'web',
'es6'
] : [
'web',
'es6'
];
// https://webpack.js.org/configuration/devtool/#development
if (ctx.isDevelopment) {
// `eval-source-map` provides full-fidelity source maps for the
// original source, including columns and original variable names.
// This is desirable so the in-browser debugger can correctly pause
// and show scoped variables with their original names.
config.devtool = 'eval-source-map';
} else {
if (ctx.isEdgeRuntime || ctx.isServer && ctx.serverSourceMaps || // Enable browser sourcemaps:
ctx.productionBrowserSourceMaps && ctx.isClient) {
config.devtool = 'source-map';
} else {
config.devtool = false;
}
}
if (!config.module) {
config.module = {
rules: []
};
}
config.plugins ??= [];
if (config.devtool === 'source-map' && !process.env.NEXT_RSPACK) {
config.plugins.push(new _devtoolsignorelistplugin.default({
shouldIgnorePath
}));
} else if (config.devtool === 'eval-source-map') {
// We're using a fork of `eval-source-map`
config.devtool = false;
if (process.env.NEXT_RSPACK) {
var _config_output;
config.plugins.push(new ((0, _getrspack.getRspackCore)()).EvalSourceMapDevToolPlugin({
moduleFilenameTemplate: (_config_output = config.output) == null ? void 0 : _config_output.devtoolModuleFilenameTemplate
}));
} else {
var _config_output1;
config.plugins.push(new _evalsourcemapdevtoolplugin.default({
moduleFilenameTemplate: (_config_output1 = config.output) == null ? void 0 : _config_output1.devtoolModuleFilenameTemplate,
shouldIgnorePath
}));
}
}
// TODO: add codemod for "Should not import the named export" with JSON files
// config.module.strictExportPresence = !isWebpack5
return config;
});
//# sourceMappingURL=base.js.map
File diff suppressed because one or more lines are too long
+5
View File
@@ -0,0 +1,5 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { ConfigurationContext } from '../../utils';
export declare const regexLikeCss: RegExp;
export declare function lazyPostCSS(rootDirectory: string, supportedBrowsers: string[] | undefined, disablePostcssPresetEnv: boolean | undefined, useLightningcss: boolean | undefined): Promise<any>;
export declare const css: import("lodash").CurriedFunction2<ConfigurationContext, webpack.Configuration, Promise<webpack.Configuration>>;
+573
View File
@@ -0,0 +1,573 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
css: null,
lazyPostCSS: null,
regexLikeCss: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
css: function() {
return css;
},
lazyPostCSS: function() {
return lazyPostCSS;
},
regexLikeCss: function() {
return regexLikeCss;
}
});
const _lodashcurry = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/lodash.curry"));
const _helpers = require("../../helpers");
const _utils = require("../../utils");
const _loaders = require("./loaders");
const _nextfont = require("./loaders/next-font");
const _messages = require("./messages");
const _plugins = require("./plugins");
const _nonnullable = require("../../../../../lib/non-nullable");
const _constants = require("../../../../../lib/constants");
const _getrspack = require("../../../../../shared/lib/get-rspack");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const regexLikeCss = /\.(css|scss|sass)$/;
// RegExps for Style Sheets
const regexCssGlobal = /(?<!\.module)\.css$/;
const regexCssModules = /\.module\.css$/;
// RegExps for Syntactically Awesome Style Sheets
const regexSassGlobal = /(?<!\.module)\.(scss|sass)$/;
const regexSassModules = /\.module\.(scss|sass)$/;
const APP_LAYER_RULE = {
or: [
_constants.WEBPACK_LAYERS.reactServerComponents,
_constants.WEBPACK_LAYERS.serverSideRendering,
_constants.WEBPACK_LAYERS.appPagesBrowser
]
};
const PAGES_LAYER_RULE = {
not: [
_constants.WEBPACK_LAYERS.reactServerComponents,
_constants.WEBPACK_LAYERS.serverSideRendering,
_constants.WEBPACK_LAYERS.appPagesBrowser
]
};
/**
* Mark a rule as removable if built-in CSS support is disabled
*/ function markRemovable(r) {
Object.defineProperty(r, Symbol.for('__next_css_remove'), {
enumerable: false,
value: true
});
return r;
}
let postcssInstancePromise;
async function lazyPostCSS(rootDirectory, supportedBrowsers, disablePostcssPresetEnv, useLightningcss) {
if (!postcssInstancePromise) {
postcssInstancePromise = (async ()=>{
const postcss = require('postcss');
// @ts-ignore backwards compat
postcss.plugin = function postcssPlugin(name, initializer) {
function creator(...args) {
let transformer = initializer(...args);
transformer.postcssPlugin = name;
// transformer.postcssVersion = new Processor().version
return transformer;
}
let cache;
Object.defineProperty(creator, 'postcss', {
get () {
if (!cache) cache = creator();
return cache;
}
});
creator.process = function(css, processOpts, pluginOpts) {
return postcss([
creator(pluginOpts)
]).process(css, processOpts);
};
return creator;
};
// @ts-ignore backwards compat
postcss.vendor = {
/**
* Returns the vendor prefix extracted from an input string.
*
* @example
* postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'
* postcss.vendor.prefix('tab-size') //=> ''
*/ prefix: function prefix(prop) {
const match = prop.match(/^(-\w+-)/);
if (match) {
return match[0];
}
return '';
},
/**
* Returns the input string stripped of its vendor prefix.
*
* @example
* postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
*/ unprefixed: function unprefixed(/**
* String with or without vendor prefix.
*/ prop) {
return prop.replace(/^-\w+-/, '');
}
};
const postCssPlugins = await (0, _plugins.getPostCssPlugins)(rootDirectory, supportedBrowsers, disablePostcssPresetEnv, useLightningcss);
return {
postcss,
postcssWithPlugins: postcss(postCssPlugins)
};
})();
}
return postcssInstancePromise;
}
const css = (0, _lodashcurry.default)(async function css(ctx, config) {
const isRspack = Boolean(process.env.NEXT_RSPACK);
const { prependData: sassPrependData, additionalData: sassAdditionalData, implementation: sassImplementation, ...sassOptions } = ctx.sassOptions;
const lazyPostCSSInitializer = ()=>lazyPostCSS(ctx.rootDirectory, ctx.supportedBrowsers, ctx.experimental.disablePostcssPresetEnv, ctx.experimental.useLightningcss);
const sassPreprocessors = [
// First, process files with `sass-loader`: this inlines content, and
// compiles away the proprietary syntax.
{
loader: require.resolve('next/dist/compiled/sass-loader'),
options: {
implementation: sassImplementation,
// Source maps are required so that `resolve-url-loader` can locate
// files original to their source directory.
sourceMap: true,
sassOptions,
additionalData: sassPrependData || sassAdditionalData
}
},
// Then, `sass-loader` will have passed-through CSS imports as-is instead
// of inlining them. Because they were inlined, the paths are no longer
// correct.
// To fix this, we use `resolve-url-loader` to rewrite the CSS
// imports to real file paths.
{
loader: require.resolve('../../../loaders/resolve-url-loader/index'),
options: {
postcss: lazyPostCSSInitializer,
// Source maps are not required here, but we may as well emit
// them.
sourceMap: true
}
}
];
const fns = [];
const googleLoader = require.resolve('next/dist/compiled/@next/font/google/loader');
const localLoader = require.resolve('next/dist/compiled/@next/font/local/loader');
const nextFontLoaders = [
[
require.resolve('next/font/google/target.css'),
googleLoader
],
[
require.resolve('next/font/local/target.css'),
localLoader
]
];
nextFontLoaders.forEach(([fontLoaderTarget, fontLoaderPath])=>{
// Matches the resolved font loaders noop files to run next-font-loader
fns.push((0, _helpers.loader)({
oneOf: [
markRemovable({
sideEffects: false,
test: fontLoaderTarget,
use: (0, _nextfont.getNextFontLoader)(ctx, lazyPostCSSInitializer, fontLoaderPath)
})
]
}));
});
// CSS cannot be imported in _document. This comes before everything because
// global CSS nor CSS modules work in said file.
fns.push((0, _helpers.loader)({
oneOf: [
markRemovable({
test: regexLikeCss,
// Use a loose regex so we don't have to crawl the file system to
// find the real file name (if present).
issuer: /pages[\\/]_document\./,
use: {
loader: 'error-loader',
options: {
reason: (0, _messages.getCustomDocumentError)()
}
}
})
]
}));
const shouldIncludeExternalCSSImports = !!ctx.experimental.craCompat || !!ctx.transpilePackages;
// CSS modules & SASS modules support. They are allowed to be imported in anywhere.
fns.push(// CSS Modules should never have side effects. This setting will
// allow unused CSS to be removed from the production build.
// We ensure this by disallowing `:global()` CSS at the top-level
// via the `pure` mode in `css-loader`.
(0, _helpers.loader)({
oneOf: [
// For app dir, we need to match the specific app layer.
ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexCssModules,
issuerLayer: APP_LAYER_RULE,
use: [
{
loader: require.resolve('../../../loaders/next-flight-css-loader'),
options: {
cssModules: true
}
},
...(0, _loaders.getCssModuleLoader)({
...ctx,
isAppDir: true
}, lazyPostCSSInitializer)
]
}) : null,
markRemovable({
sideEffects: true,
test: regexCssModules,
issuerLayer: PAGES_LAYER_RULE,
use: (0, _loaders.getCssModuleLoader)({
...ctx,
isAppDir: false
}, lazyPostCSSInitializer)
})
].filter(_nonnullable.nonNullable)
}), // Opt-in support for Sass (using .scss or .sass extensions).
// Sass Modules should never have side effects. This setting will
// allow unused Sass to be removed from the production build.
// We ensure this by disallowing `:global()` Sass at the top-level
// via the `pure` mode in `css-loader`.
(0, _helpers.loader)({
oneOf: [
// For app dir, we need to match the specific app layer.
ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexSassModules,
issuerLayer: APP_LAYER_RULE,
use: [
{
loader: require.resolve('../../../loaders/next-flight-css-loader'),
options: {
cssModules: true
}
},
...(0, _loaders.getCssModuleLoader)({
...ctx,
isAppDir: true
}, lazyPostCSSInitializer, sassPreprocessors)
]
}) : null,
markRemovable({
sideEffects: true,
test: regexSassModules,
issuerLayer: PAGES_LAYER_RULE,
use: (0, _loaders.getCssModuleLoader)({
...ctx,
isAppDir: false
}, lazyPostCSSInitializer, sassPreprocessors)
})
].filter(_nonnullable.nonNullable)
}), // Throw an error for CSS Modules used outside their supported scope
(0, _helpers.loader)({
oneOf: [
markRemovable({
test: [
regexCssModules,
regexSassModules
],
use: {
loader: 'error-loader',
options: {
reason: (0, _messages.getLocalModuleImportError)()
}
}
})
]
}));
// Global CSS and SASS support.
if (ctx.isServer) {
fns.push((0, _helpers.loader)({
oneOf: [
ctx.hasAppDir && !ctx.isProduction ? markRemovable({
sideEffects: true,
test: [
regexCssGlobal,
regexSassGlobal
],
issuerLayer: APP_LAYER_RULE,
use: {
loader: require.resolve('../../../loaders/next-flight-css-loader'),
options: {
cssModules: false
}
}
}) : null,
markRemovable({
// CSS imports have side effects, even on the server side.
sideEffects: true,
test: [
regexCssGlobal,
regexSassGlobal
],
use: require.resolve('next/dist/compiled/ignore-loader')
})
].filter(_nonnullable.nonNullable)
}));
} else {
// External CSS files are allowed to be loaded when any of the following is true:
// - hasAppDir: all CSS files are allowed
// - If the CSS file is located in `node_modules`
// - If the CSS file is located in another package in a monorepo (outside of the current rootDir)
// - If the issuer is pages/_app (matched later)
const allowedPagesGlobalCSSPath = ctx.hasAppDir ? undefined : {
and: [
{
or: [
/node_modules/,
{
not: [
ctx.rootDirectory
]
}
]
}
]
};
const allowedPagesGlobalCSSIssuer = ctx.hasAppDir ? undefined : shouldIncludeExternalCSSImports ? undefined : {
and: [
ctx.rootDirectory
],
not: [
/node_modules/
]
};
fns.push((0, _helpers.loader)({
oneOf: [
...ctx.hasAppDir ? [
markRemovable({
sideEffects: true,
test: regexCssGlobal,
issuerLayer: APP_LAYER_RULE,
use: [
{
loader: require.resolve('../../../loaders/next-flight-css-loader'),
options: {
cssModules: false
}
},
...(0, _loaders.getGlobalCssLoader)({
...ctx,
isAppDir: true
}, lazyPostCSSInitializer)
]
}),
markRemovable({
sideEffects: true,
test: regexSassGlobal,
issuerLayer: APP_LAYER_RULE,
use: [
{
loader: require.resolve('../../../loaders/next-flight-css-loader'),
options: {
cssModules: false
}
},
...(0, _loaders.getGlobalCssLoader)({
...ctx,
isAppDir: true
}, lazyPostCSSInitializer, sassPreprocessors)
]
})
] : [],
markRemovable({
sideEffects: true,
test: regexCssGlobal,
include: allowedPagesGlobalCSSPath,
issuer: allowedPagesGlobalCSSIssuer,
issuerLayer: PAGES_LAYER_RULE,
use: (0, _loaders.getGlobalCssLoader)({
...ctx,
isAppDir: false
}, lazyPostCSSInitializer)
}),
markRemovable({
sideEffects: true,
test: regexSassGlobal,
include: allowedPagesGlobalCSSPath,
issuer: allowedPagesGlobalCSSIssuer,
issuerLayer: PAGES_LAYER_RULE,
use: (0, _loaders.getGlobalCssLoader)({
...ctx,
isAppDir: false
}, lazyPostCSSInitializer, sassPreprocessors)
})
].filter(_nonnullable.nonNullable)
}));
if (ctx.customAppFile) {
fns.push((0, _helpers.loader)({
oneOf: [
markRemovable({
sideEffects: true,
test: regexCssGlobal,
issuer: {
and: [
ctx.customAppFile
]
},
use: (0, _loaders.getGlobalCssLoader)({
...ctx,
isAppDir: false
}, lazyPostCSSInitializer)
})
]
}), (0, _helpers.loader)({
oneOf: [
markRemovable({
sideEffects: true,
test: regexSassGlobal,
issuer: {
and: [
ctx.customAppFile
]
},
use: (0, _loaders.getGlobalCssLoader)({
...ctx,
isAppDir: false
}, lazyPostCSSInitializer, sassPreprocessors)
})
]
}));
}
}
// Throw an error for Global CSS used inside of `node_modules`
if (!shouldIncludeExternalCSSImports) {
fns.push((0, _helpers.loader)({
oneOf: [
markRemovable({
test: [
regexCssGlobal,
regexSassGlobal
],
issuer: {
and: [
/node_modules/
]
},
use: {
loader: 'error-loader',
options: {
reason: (0, _messages.getGlobalModuleImportError)()
}
}
})
]
}));
}
// Throw an error for Global CSS used outside of our custom <App> file
fns.push((0, _helpers.loader)({
oneOf: [
markRemovable({
test: [
regexCssGlobal,
regexSassGlobal
],
issuer: ctx.hasAppDir ? {
// If it's inside the app dir, but not importing from a layout file,
// throw an error.
and: [
ctx.rootDirectory
],
not: [
/layout\.(js|mjs|jsx|ts|tsx)$/
]
} : undefined,
use: {
loader: 'error-loader',
options: {
reason: (0, _messages.getGlobalImportError)()
}
}
})
]
}));
if (ctx.isClient) {
// Automatically transform references to files (i.e. url()) into URLs
// e.g. url(./logo.svg)
fns.push((0, _helpers.loader)({
oneOf: [
markRemovable({
// 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$/,
/\.webpack\[[^\]]+\]$/
],
// `asset/resource` always emits a URL reference, where `asset`
// might inline the asset as a data URI
type: 'asset/resource'
})
]
}));
}
// Enable full mini-css-extract-plugin hmr for prod mode pages or app dir
if (ctx.isClient && (ctx.isProduction || ctx.hasAppDir)) {
// Extract CSS as CSS file(s) in the client-side production bundle.
const MiniCssExtractPlugin = isRspack ? (0, _getrspack.getRspackCore)().CssExtractRspackPlugin : require('../../../plugins/mini-css-extract-plugin').default;
fns.push((0, _helpers.plugin)(// @ts-ignore webpack 5 compat
new MiniCssExtractPlugin({
filename: ctx.isProduction ? 'static/css/[contenthash].css' : 'static/css/[name].css',
chunkFilename: ctx.isProduction ? 'static/css/[contenthash].css' : 'static/css/[name].css',
// Next.js guarantees that CSS order "doesn't matter", due to imposed
// restrictions:
// 1. Global CSS can only be defined in a single entrypoint (_app)
// 2. CSS Modules generate scoped class names by default and cannot
// include Global CSS (:global() selector).
//
// While not a perfect guarantee (e.g. liberal use of `:global()`
// selector), this assumption is required to code-split CSS.
//
// If this warning were to trigger, it'd be unactionable by the user,
// but likely not valid -- so we disable it.
ignoreOrder: true,
insert: function(linkTag) {
if (typeof _N_E_STYLE_LOAD === 'function') {
// Avoid destructuring and optional-chaining here: this function
// is serialized as a string by mini-css-extract-plugin and
// injected directly into the browser bundle without further
// transpilation. Destructuring (`const { x } = obj`) breaks on
// browsers that pre-date ES2015 support (e.g. Chrome <49).
var href = linkTag.href;
var onload = linkTag.onload;
var onerror = linkTag.onerror;
_N_E_STYLE_LOAD(href.indexOf(window.location.origin) === 0 ? new URL(href).pathname : href).then(function() {
if (onload) onload.call(linkTag, {
type: 'load'
});
}, function() {
if (onerror) onerror.call(linkTag, {});
});
} else {
document.head.appendChild(linkTag);
}
}
})));
}
const fn = (0, _utils.pipe)(...fns);
return fn(config);
});
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export declare function getClientStyleLoader({ hasAppDir, isAppDir, isDevelopment, assetPrefix, experimentalInlineCss, }: {
hasAppDir: boolean;
isAppDir?: boolean;
isDevelopment: boolean;
assetPrefix: string;
experimentalInlineCss?: boolean;
}): webpack.RuleSetUseItem;
@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getClientStyleLoader", {
enumerable: true,
get: function() {
return getClientStyleLoader;
}
});
const _getrspack = require("../../../../../../shared/lib/get-rspack");
function getClientStyleLoader({ hasAppDir, isAppDir, isDevelopment, assetPrefix, experimentalInlineCss }) {
const isRspack = Boolean(process.env.NEXT_RSPACK);
const shouldEnableApp = typeof isAppDir === 'boolean' ? isAppDir : hasAppDir;
// Keep next-style-loader for development mode in `pages/`
if (isDevelopment && !shouldEnableApp) {
return {
loader: 'next-style-loader',
options: {
insert: function(element) {
// By default, style-loader injects CSS into the bottom
// of <head>. This causes ordering problems between dev
// and prod. To fix this, we render a <noscript> tag as
// an anchor for the styles to be placed before. These
// styles will be applied _before_ <style jsx global>.
// These elements should always exist. If they do not,
// this code should fail.
var anchorElement = document.querySelector('#__next_css__DO_NOT_USE__');
var parentNode = anchorElement.parentNode// Normally <head>
;
// Each style tag should be placed right before our
// anchor. By inserting before and not after, we do not
// need to track the last inserted element.
parentNode.insertBefore(element, anchorElement);
}
}
};
}
const MiniCssExtractPlugin = isRspack ? (0, _getrspack.getRspackCore)().rspack.CssExtractRspackPlugin : require('../../../../plugins/mini-css-extract-plugin').default;
return {
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: experimentalInlineCss ? '/' : `${assetPrefix}/_next/`,
esModule: false
}
};
}
//# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/build/webpack/config/blocks/css/loaders/client.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { getRspackCore } from '../../../../../../shared/lib/get-rspack'\n\nexport function getClientStyleLoader({\n hasAppDir,\n isAppDir,\n isDevelopment,\n assetPrefix,\n experimentalInlineCss,\n}: {\n hasAppDir: boolean\n isAppDir?: boolean\n isDevelopment: boolean\n assetPrefix: string\n experimentalInlineCss?: boolean\n}): webpack.RuleSetUseItem {\n const isRspack = Boolean(process.env.NEXT_RSPACK)\n const shouldEnableApp = typeof isAppDir === 'boolean' ? isAppDir : hasAppDir\n\n // Keep next-style-loader for development mode in `pages/`\n if (isDevelopment && !shouldEnableApp) {\n return {\n loader: 'next-style-loader',\n options: {\n insert: function (element: Node) {\n // By default, style-loader injects CSS into the bottom\n // of <head>. This causes ordering problems between dev\n // and prod. To fix this, we render a <noscript> tag as\n // an anchor for the styles to be placed before. These\n // styles will be applied _before_ <style jsx global>.\n\n // These elements should always exist. If they do not,\n // this code should fail.\n var anchorElement = document.querySelector(\n '#__next_css__DO_NOT_USE__'\n )!\n var parentNode = anchorElement.parentNode! // Normally <head>\n\n // Each style tag should be placed right before our\n // anchor. By inserting before and not after, we do not\n // need to track the last inserted element.\n parentNode.insertBefore(element, anchorElement)\n },\n },\n }\n }\n\n const MiniCssExtractPlugin = isRspack\n ? getRspackCore().rspack.CssExtractRspackPlugin\n : (\n require('../../../../plugins/mini-css-extract-plugin') as typeof import('../../../../plugins/mini-css-extract-plugin')\n ).default\n\n return {\n loader: MiniCssExtractPlugin.loader,\n options: {\n publicPath: experimentalInlineCss ? '/' : `${assetPrefix}/_next/`,\n esModule: false,\n },\n }\n}\n"],"names":["getClientStyleLoader","hasAppDir","isAppDir","isDevelopment","assetPrefix","experimentalInlineCss","isRspack","Boolean","process","env","NEXT_RSPACK","shouldEnableApp","loader","options","insert","element","anchorElement","document","querySelector","parentNode","insertBefore","MiniCssExtractPlugin","getRspackCore","rspack","CssExtractRspackPlugin","require","default","publicPath","esModule"],"mappings":";;;;+BAGgBA;;;eAAAA;;;2BAFc;AAEvB,SAASA,qBAAqB,EACnCC,SAAS,EACTC,QAAQ,EACRC,aAAa,EACbC,WAAW,EACXC,qBAAqB,EAOtB;IACC,MAAMC,WAAWC,QAAQC,QAAQC,GAAG,CAACC,WAAW;IAChD,MAAMC,kBAAkB,OAAOT,aAAa,YAAYA,WAAWD;IAEnE,0DAA0D;IAC1D,IAAIE,iBAAiB,CAACQ,iBAAiB;QACrC,OAAO;YACLC,QAAQ;YACRC,SAAS;gBACPC,QAAQ,SAAUC,OAAa;oBAC7B,uDAAuD;oBACvD,uDAAuD;oBACvD,uDAAuD;oBACvD,sDAAsD;oBACtD,sDAAsD;oBAEtD,sDAAsD;oBACtD,yBAAyB;oBACzB,IAAIC,gBAAgBC,SAASC,aAAa,CACxC;oBAEF,IAAIC,aAAaH,cAAcG,UAAU,AAAE,kBAAkB;;oBAE7D,mDAAmD;oBACnD,uDAAuD;oBACvD,2CAA2C;oBAC3CA,WAAWC,YAAY,CAACL,SAASC;gBACnC;YACF;QACF;IACF;IAEA,MAAMK,uBAAuBf,WACzBgB,IAAAA,wBAAa,IAAGC,MAAM,CAACC,sBAAsB,GAC7C,AACEC,QAAQ,+CACRC,OAAO;IAEb,OAAO;QACLd,QAAQS,qBAAqBT,MAAM;QACnCC,SAAS;YACPc,YAAYtB,wBAAwB,MAAM,GAAGD,YAAY,OAAO,CAAC;YACjEwB,UAAU;QACZ;IACF;AACF","ignoreList":[0]}
@@ -0,0 +1 @@
export declare function cssFileResolve(url: string, _resourcePath: string, urlImports: any): boolean;
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "cssFileResolve", {
enumerable: true,
get: function() {
return cssFileResolve;
}
});
function cssFileResolve(url, _resourcePath, urlImports) {
if (url.startsWith('/')) {
return false;
}
if (!urlImports && /^[a-z][a-z0-9+.-]*:/i.test(url)) {
return false;
}
return true;
}
//# sourceMappingURL=file-resolve.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/build/webpack/config/blocks/css/loaders/file-resolve.ts"],"sourcesContent":["export function cssFileResolve(\n url: string,\n _resourcePath: string,\n urlImports: any\n) {\n if (url.startsWith('/')) {\n return false\n }\n if (!urlImports && /^[a-z][a-z0-9+.-]*:/i.test(url)) {\n return false\n }\n return true\n}\n"],"names":["cssFileResolve","url","_resourcePath","urlImports","startsWith","test"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,eACdC,GAAW,EACXC,aAAqB,EACrBC,UAAe;IAEf,IAAIF,IAAIG,UAAU,CAAC,MAAM;QACvB,OAAO;IACT;IACA,IAAI,CAACD,cAAc,uBAAuBE,IAAI,CAACJ,MAAM;QACnD,OAAO;IACT;IACA,OAAO;AACT","ignoreList":[0]}
@@ -0,0 +1,2 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export declare function getCssModuleLocalIdent(context: webpack.LoaderContext<{}>, _: any, exportName: string, options: object): any;
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getCssModuleLocalIdent", {
enumerable: true,
get: function() {
return getCssModuleLocalIdent;
}
});
const _loaderutils3 = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/loader-utils3"));
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const regexLikeIndexModule = /(?<!pages[\\/])index\.module\.(scss|sass|css)$/;
function getCssModuleLocalIdent(context, _, exportName, options) {
const relativePath = _path.default.relative(context.rootContext, context.resourcePath).replace(/\\+/g, '/');
// Generate a more meaningful name (parent folder) when the user names the
// file `index.module.css`.
const fileNameOrFolder = regexLikeIndexModule.test(relativePath) ? '[folder]' : '[name]';
// Generate a hash to make the class name unique.
const hash = _loaderutils3.default.getHashDigest(Buffer.from(`filePath:${relativePath}#className:${exportName}`), 'sha1', 'base64', 5);
// Have webpack interpolate the `[folder]` or `[name]` to its real value.
return _loaderutils3.default.interpolateName(context, fileNameOrFolder + '_' + exportName + '__' + hash, options).replace(// Webpack name interpolation returns `about.module_root__2oFM9` for
// `.root {}` inside a file named `about.module.css`. Let's simplify
// this.
/\.module_/, '_')// Replace invalid symbols with underscores instead of escaping
// https://mathiasbynens.be/notes/css-escapes#identifiers-strings
.replace(/[^a-zA-Z0-9-_]/g, '_')// "they cannot start with a digit, two hyphens, or a hyphen followed by a digit [sic]"
// https://www.w3.org/TR/CSS21/syndata.html#characters
.replace(/^(\d|--|-\d)/, '__$1');
}
//# sourceMappingURL=getCssModuleLocalIdent.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts"],"sourcesContent":["import loaderUtils from 'next/dist/compiled/loader-utils3'\nimport path from 'path'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\n\nconst regexLikeIndexModule = /(?<!pages[\\\\/])index\\.module\\.(scss|sass|css)$/\n\nexport function getCssModuleLocalIdent(\n context: webpack.LoaderContext<{}>,\n _: any,\n exportName: string,\n options: object\n) {\n const relativePath = path\n .relative(context.rootContext, context.resourcePath)\n .replace(/\\\\+/g, '/')\n\n // Generate a more meaningful name (parent folder) when the user names the\n // file `index.module.css`.\n const fileNameOrFolder = regexLikeIndexModule.test(relativePath)\n ? '[folder]'\n : '[name]'\n\n // Generate a hash to make the class name unique.\n const hash = loaderUtils.getHashDigest(\n Buffer.from(`filePath:${relativePath}#className:${exportName}`),\n 'sha1',\n 'base64',\n 5\n )\n\n // Have webpack interpolate the `[folder]` or `[name]` to its real value.\n return (\n loaderUtils\n .interpolateName(\n context,\n fileNameOrFolder + '_' + exportName + '__' + hash,\n options\n )\n .replace(\n // Webpack name interpolation returns `about.module_root__2oFM9` for\n // `.root {}` inside a file named `about.module.css`. Let's simplify\n // this.\n /\\.module_/,\n '_'\n )\n // Replace invalid symbols with underscores instead of escaping\n // https://mathiasbynens.be/notes/css-escapes#identifiers-strings\n .replace(/[^a-zA-Z0-9-_]/g, '_')\n // \"they cannot start with a digit, two hyphens, or a hyphen followed by a digit [sic]\"\n // https://www.w3.org/TR/CSS21/syndata.html#characters\n .replace(/^(\\d|--|-\\d)/, '__$1')\n )\n}\n"],"names":["getCssModuleLocalIdent","regexLikeIndexModule","context","_","exportName","options","relativePath","path","relative","rootContext","resourcePath","replace","fileNameOrFolder","test","hash","loaderUtils","getHashDigest","Buffer","from","interpolateName"],"mappings":";;;;+BAMgBA;;;eAAAA;;;qEANQ;6DACP;;;;;;AAGjB,MAAMC,uBAAuB;AAEtB,SAASD,uBACdE,OAAkC,EAClCC,CAAM,EACNC,UAAkB,EAClBC,OAAe;IAEf,MAAMC,eAAeC,aAAI,CACtBC,QAAQ,CAACN,QAAQO,WAAW,EAAEP,QAAQQ,YAAY,EAClDC,OAAO,CAAC,QAAQ;IAEnB,0EAA0E;IAC1E,2BAA2B;IAC3B,MAAMC,mBAAmBX,qBAAqBY,IAAI,CAACP,gBAC/C,aACA;IAEJ,iDAAiD;IACjD,MAAMQ,OAAOC,qBAAW,CAACC,aAAa,CACpCC,OAAOC,IAAI,CAAC,CAAC,SAAS,EAAEZ,aAAa,WAAW,EAAEF,YAAY,GAC9D,QACA,UACA;IAGF,yEAAyE;IACzE,OACEW,qBAAW,CACRI,eAAe,CACdjB,SACAU,mBAAmB,MAAMR,aAAa,OAAOU,MAC7CT,SAEDM,OAAO,CACN,oEAAoE;IACpE,oEAAoE;IACpE,QAAQ;IACR,aACA,IAEF,+DAA+D;IAC/D,iEAAiE;KAChEA,OAAO,CAAC,mBAAmB,IAC5B,uFAAuF;IACvF,sDAAsD;KACrDA,OAAO,CAAC,gBAAgB;AAE/B","ignoreList":[0]}
@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { ConfigurationContext } from '../../../utils';
export declare function getGlobalCssLoader(ctx: ConfigurationContext, postcss: any, preProcessors?: readonly webpack.RuleSetUseItem[]): webpack.RuleSetUseItem[];
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getGlobalCssLoader", {
enumerable: true,
get: function() {
return getGlobalCssLoader;
}
});
const _client = require("./client");
const _fileresolve = require("./file-resolve");
function getGlobalCssLoader(ctx, postcss, preProcessors = []) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development more or production mode style
// loader
loaders.push((0, _client.getClientStyleLoader)({
hasAppDir: ctx.hasAppDir,
isAppDir: ctx.isAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix,
experimentalInlineCss: ctx.experimental.inlineCss
}));
}
if (ctx.experimental.useLightningcss) {
loaders.push({
loader: require.resolve('../../../../loaders/lightningcss-loader/src'),
options: {
importLoaders: 1 + preProcessors.length,
url: (url, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
modules: false,
targets: ctx.supportedBrowsers,
postcss,
lightningCssFeatures: ctx.experimental.lightningCssFeatures
}
});
} else {
// Resolve CSS `@import`s and `url()`s
loaders.push({
loader: require.resolve('../../../../loaders/css-loader/src'),
options: {
postcss,
importLoaders: 1 + preProcessors.length,
// Next.js controls CSS Modules eligibility:
modules: false,
url: (url, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
deploymentId: ctx.deploymentId
}
});
// Compile CSS
loaders.push({
loader: require.resolve('../../../../loaders/postcss-loader/src'),
options: {
postcss
}
});
}
loaders.push(// Webpack loaders run like a stack, so we need to reverse the natural
// order of preprocessors.
...preProcessors.slice().reverse());
return loaders;
}
//# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/build/webpack/config/blocks/css/loaders/global.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport type { ConfigurationContext } from '../../../utils'\n\nimport { getClientStyleLoader } from './client'\nimport { cssFileResolve } from './file-resolve'\n\nexport function getGlobalCssLoader(\n ctx: ConfigurationContext,\n postcss: any,\n preProcessors: readonly webpack.RuleSetUseItem[] = []\n): webpack.RuleSetUseItem[] {\n const loaders: webpack.RuleSetUseItem[] = []\n\n if (ctx.isClient) {\n // Add appropriate development more or production mode style\n // loader\n loaders.push(\n getClientStyleLoader({\n hasAppDir: ctx.hasAppDir,\n isAppDir: ctx.isAppDir,\n isDevelopment: ctx.isDevelopment,\n assetPrefix: ctx.assetPrefix,\n experimentalInlineCss: ctx.experimental.inlineCss,\n })\n )\n }\n\n if (ctx.experimental.useLightningcss) {\n loaders.push({\n loader: require.resolve('../../../../loaders/lightningcss-loader/src'),\n options: {\n importLoaders: 1 + preProcessors.length,\n url: (url: string, resourcePath: string) =>\n cssFileResolve(url, resourcePath, ctx.experimental.urlImports),\n import: (url: string, _: any, resourcePath: string) =>\n cssFileResolve(url, resourcePath, ctx.experimental.urlImports),\n modules: false,\n targets: ctx.supportedBrowsers,\n postcss,\n lightningCssFeatures: ctx.experimental.lightningCssFeatures,\n },\n })\n } else {\n // Resolve CSS `@import`s and `url()`s\n loaders.push({\n loader: require.resolve('../../../../loaders/css-loader/src'),\n options: {\n postcss,\n importLoaders: 1 + preProcessors.length,\n // Next.js controls CSS Modules eligibility:\n modules: false,\n url: (url: string, resourcePath: string) =>\n cssFileResolve(url, resourcePath, ctx.experimental.urlImports),\n import: (url: string, _: any, resourcePath: string) =>\n cssFileResolve(url, resourcePath, ctx.experimental.urlImports),\n deploymentId: ctx.deploymentId,\n },\n })\n\n // Compile CSS\n loaders.push({\n loader: require.resolve('../../../../loaders/postcss-loader/src'),\n options: {\n postcss,\n },\n })\n }\n\n loaders.push(\n // Webpack loaders run like a stack, so we need to reverse the natural\n // order of preprocessors.\n ...preProcessors.slice().reverse()\n )\n\n return loaders\n}\n"],"names":["getGlobalCssLoader","ctx","postcss","preProcessors","loaders","isClient","push","getClientStyleLoader","hasAppDir","isAppDir","isDevelopment","assetPrefix","experimentalInlineCss","experimental","inlineCss","useLightningcss","loader","require","resolve","options","importLoaders","length","url","resourcePath","cssFileResolve","urlImports","import","_","modules","targets","supportedBrowsers","lightningCssFeatures","deploymentId","slice","reverse"],"mappings":";;;;+BAMgBA;;;eAAAA;;;wBAHqB;6BACN;AAExB,SAASA,mBACdC,GAAyB,EACzBC,OAAY,EACZC,gBAAmD,EAAE;IAErD,MAAMC,UAAoC,EAAE;IAE5C,IAAIH,IAAII,QAAQ,EAAE;QAChB,4DAA4D;QAC5D,SAAS;QACTD,QAAQE,IAAI,CACVC,IAAAA,4BAAoB,EAAC;YACnBC,WAAWP,IAAIO,SAAS;YACxBC,UAAUR,IAAIQ,QAAQ;YACtBC,eAAeT,IAAIS,aAAa;YAChCC,aAAaV,IAAIU,WAAW;YAC5BC,uBAAuBX,IAAIY,YAAY,CAACC,SAAS;QACnD;IAEJ;IAEA,IAAIb,IAAIY,YAAY,CAACE,eAAe,EAAE;QACpCX,QAAQE,IAAI,CAAC;YACXU,QAAQC,QAAQC,OAAO,CAAC;YACxBC,SAAS;gBACPC,eAAe,IAAIjB,cAAckB,MAAM;gBACvCC,KAAK,CAACA,KAAaC,eACjBC,IAAAA,2BAAc,EAACF,KAAKC,cAActB,IAAIY,YAAY,CAACY,UAAU;gBAC/DC,QAAQ,CAACJ,KAAaK,GAAQJ,eAC5BC,IAAAA,2BAAc,EAACF,KAAKC,cAActB,IAAIY,YAAY,CAACY,UAAU;gBAC/DG,SAAS;gBACTC,SAAS5B,IAAI6B,iBAAiB;gBAC9B5B;gBACA6B,sBAAsB9B,IAAIY,YAAY,CAACkB,oBAAoB;YAC7D;QACF;IACF,OAAO;QACL,sCAAsC;QACtC3B,QAAQE,IAAI,CAAC;YACXU,QAAQC,QAAQC,OAAO,CAAC;YACxBC,SAAS;gBACPjB;gBACAkB,eAAe,IAAIjB,cAAckB,MAAM;gBACvC,4CAA4C;gBAC5CO,SAAS;gBACTN,KAAK,CAACA,KAAaC,eACjBC,IAAAA,2BAAc,EAACF,KAAKC,cAActB,IAAIY,YAAY,CAACY,UAAU;gBAC/DC,QAAQ,CAACJ,KAAaK,GAAQJ,eAC5BC,IAAAA,2BAAc,EAACF,KAAKC,cAActB,IAAIY,YAAY,CAACY,UAAU;gBAC/DO,cAAc/B,IAAI+B,YAAY;YAChC;QACF;QAEA,cAAc;QACd5B,QAAQE,IAAI,CAAC;YACXU,QAAQC,QAAQC,OAAO,CAAC;YACxBC,SAAS;gBACPjB;YACF;QACF;IACF;IAEAE,QAAQE,IAAI,CACV,sEAAsE;IACtE,0BAA0B;OACvBH,cAAc8B,KAAK,GAAGC,OAAO;IAGlC,OAAO9B;AACT","ignoreList":[0]}
@@ -0,0 +1,2 @@
export * from './global';
export * from './modules';
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && __export(require("./global")) && __export(require("./modules"));
_export_star(require("./global"), exports);
_export_star(require("./modules"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
return from;
}
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/build/webpack/config/blocks/css/loaders/index.ts"],"sourcesContent":["export * from './global'\nexport * from './modules'\n"],"names":[],"mappings":";;;;;qBAAc;qBACA","ignoreList":[0]}
@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { ConfigurationContext } from '../../../utils';
export declare function getCssModuleLoader(ctx: ConfigurationContext, postcss: any, preProcessors?: readonly webpack.RuleSetUseItem[]): webpack.RuleSetUseItem[];
@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getCssModuleLoader", {
enumerable: true,
get: function() {
return getCssModuleLoader;
}
});
const _client = require("./client");
const _fileresolve = require("./file-resolve");
const _getCssModuleLocalIdent = require("./getCssModuleLocalIdent");
function getCssModuleLoader(ctx, postcss, preProcessors = []) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development more or production mode style
// loader
loaders.push((0, _client.getClientStyleLoader)({
hasAppDir: ctx.hasAppDir,
isAppDir: ctx.isAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix,
experimentalInlineCss: ctx.experimental.inlineCss
}));
}
if (ctx.experimental.useLightningcss) {
loaders.push({
loader: require.resolve('../../../../loaders/lightningcss-loader/src'),
options: {
importLoaders: 1 + preProcessors.length,
url: (url, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
modules: {
// Do not transform class names (CJS mode backwards compatibility):
exportLocalsConvention: 'asIs',
// Server-side (Node.js) rendering support:
exportOnlyLocals: ctx.isServer
},
targets: ctx.supportedBrowsers,
postcss,
lightningCssFeatures: ctx.experimental.lightningCssFeatures
}
});
} else {
// Resolve CSS `@import`s and `url()`s
loaders.push({
loader: require.resolve('../../../../loaders/css-loader/src'),
options: {
postcss,
importLoaders: 1 + preProcessors.length,
// Use CJS mode for backwards compatibility:
esModule: false,
url: (url, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
modules: {
// Do not transform class names (CJS mode backwards compatibility):
exportLocalsConvention: 'asIs',
// Server-side (Node.js) rendering support:
exportOnlyLocals: ctx.isServer,
// Disallow global style exports so we can code-split CSS and
// not worry about loading order.
mode: 'pure',
// Generate a friendly production-ready name so it's
// reasonably understandable. The same name is used for
// development.
// TODO: Consider making production reduce this to a single
// character?
getLocalIdent: _getCssModuleLocalIdent.getCssModuleLocalIdent
},
deploymentId: ctx.deploymentId
}
});
// Compile CSS
loaders.push({
loader: require.resolve('../../../../loaders/postcss-loader/src'),
options: {
postcss
}
});
}
loaders.push(// Webpack loaders run like a stack, so we need to reverse the natural
// order of preprocessors.
...preProcessors.slice().reverse());
return loaders;
}
//# sourceMappingURL=modules.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { ConfigurationContext } from '../../../utils';
export declare function getNextFontLoader(ctx: ConfigurationContext, postcss: any, fontLoaderPath: string): webpack.RuleSetUseItem[];
@@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getNextFontLoader", {
enumerable: true,
get: function() {
return getNextFontLoader;
}
});
const _client = require("./client");
const _fileresolve = require("./file-resolve");
function getNextFontLoader(ctx, postcss, fontLoaderPath) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development mode or production mode style
// loader
loaders.push((0, _client.getClientStyleLoader)({
hasAppDir: ctx.hasAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix
}));
}
loaders.push({
loader: require.resolve('../../../../loaders/css-loader/src'),
options: {
postcss,
importLoaders: 1,
// Use CJS mode for backwards compatibility:
esModule: false,
url: (url, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>(0, _fileresolve.cssFileResolve)(url, resourcePath, ctx.experimental.urlImports),
modules: {
// Do not transform class names (CJS mode backwards compatibility):
exportLocalsConvention: 'asIs',
// Server-side (Node.js) rendering support:
exportOnlyLocals: ctx.isServer,
// Disallow global style exports so we can code-split CSS and
// not worry about loading order.
mode: 'pure',
getLocalIdent: (_context, _localIdentName, exportName, _options, meta)=>{
// hash from next-font-loader
return `__${exportName}_${meta.fontFamilyHash}`;
}
},
fontLoader: true
}
});
loaders.push({
loader: 'next-font-loader',
options: {
isDev: ctx.isDevelopment,
isServer: ctx.isServer,
assetPrefix: ctx.assetPrefix,
deploymentId: ctx.deploymentId,
fontLoaderPath,
postcss
}
});
return loaders;
}
//# sourceMappingURL=next-font.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/build/webpack/config/blocks/css/loaders/next-font.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport type { ConfigurationContext } from '../../../utils'\nimport { getClientStyleLoader } from './client'\nimport { cssFileResolve } from './file-resolve'\n\nexport function getNextFontLoader(\n ctx: ConfigurationContext,\n postcss: any,\n fontLoaderPath: string\n): webpack.RuleSetUseItem[] {\n const loaders: webpack.RuleSetUseItem[] = []\n\n if (ctx.isClient) {\n // Add appropriate development mode or production mode style\n // loader\n loaders.push(\n getClientStyleLoader({\n hasAppDir: ctx.hasAppDir,\n isDevelopment: ctx.isDevelopment,\n assetPrefix: ctx.assetPrefix,\n })\n )\n }\n\n loaders.push({\n loader: require.resolve('../../../../loaders/css-loader/src'),\n options: {\n postcss,\n importLoaders: 1,\n // Use CJS mode for backwards compatibility:\n esModule: false,\n url: (url: string, resourcePath: string) =>\n cssFileResolve(url, resourcePath, ctx.experimental.urlImports),\n import: (url: string, _: any, resourcePath: string) =>\n cssFileResolve(url, resourcePath, ctx.experimental.urlImports),\n modules: {\n // Do not transform class names (CJS mode backwards compatibility):\n exportLocalsConvention: 'asIs',\n // Server-side (Node.js) rendering support:\n exportOnlyLocals: ctx.isServer,\n // Disallow global style exports so we can code-split CSS and\n // not worry about loading order.\n mode: 'pure',\n getLocalIdent: (\n _context: any,\n _localIdentName: any,\n exportName: string,\n _options: any,\n meta: any\n ) => {\n // hash from next-font-loader\n return `__${exportName}_${meta.fontFamilyHash}`\n },\n },\n fontLoader: true,\n },\n })\n\n loaders.push({\n loader: 'next-font-loader',\n options: {\n isDev: ctx.isDevelopment,\n isServer: ctx.isServer,\n assetPrefix: ctx.assetPrefix,\n deploymentId: ctx.deploymentId,\n fontLoaderPath,\n postcss,\n },\n })\n\n return loaders\n}\n"],"names":["getNextFontLoader","ctx","postcss","fontLoaderPath","loaders","isClient","push","getClientStyleLoader","hasAppDir","isDevelopment","assetPrefix","loader","require","resolve","options","importLoaders","esModule","url","resourcePath","cssFileResolve","experimental","urlImports","import","_","modules","exportLocalsConvention","exportOnlyLocals","isServer","mode","getLocalIdent","_context","_localIdentName","exportName","_options","meta","fontFamilyHash","fontLoader","isDev","deploymentId"],"mappings":";;;;+BAKgBA;;;eAAAA;;;wBAHqB;6BACN;AAExB,SAASA,kBACdC,GAAyB,EACzBC,OAAY,EACZC,cAAsB;IAEtB,MAAMC,UAAoC,EAAE;IAE5C,IAAIH,IAAII,QAAQ,EAAE;QAChB,4DAA4D;QAC5D,SAAS;QACTD,QAAQE,IAAI,CACVC,IAAAA,4BAAoB,EAAC;YACnBC,WAAWP,IAAIO,SAAS;YACxBC,eAAeR,IAAIQ,aAAa;YAChCC,aAAaT,IAAIS,WAAW;QAC9B;IAEJ;IAEAN,QAAQE,IAAI,CAAC;QACXK,QAAQC,QAAQC,OAAO,CAAC;QACxBC,SAAS;YACPZ;YACAa,eAAe;YACf,4CAA4C;YAC5CC,UAAU;YACVC,KAAK,CAACA,KAAaC,eACjBC,IAAAA,2BAAc,EAACF,KAAKC,cAAcjB,IAAImB,YAAY,CAACC,UAAU;YAC/DC,QAAQ,CAACL,KAAaM,GAAQL,eAC5BC,IAAAA,2BAAc,EAACF,KAAKC,cAAcjB,IAAImB,YAAY,CAACC,UAAU;YAC/DG,SAAS;gBACP,mEAAmE;gBACnEC,wBAAwB;gBACxB,2CAA2C;gBAC3CC,kBAAkBzB,IAAI0B,QAAQ;gBAC9B,6DAA6D;gBAC7D,iCAAiC;gBACjCC,MAAM;gBACNC,eAAe,CACbC,UACAC,iBACAC,YACAC,UACAC;oBAEA,6BAA6B;oBAC7B,OAAO,CAAC,EAAE,EAAEF,WAAW,CAAC,EAAEE,KAAKC,cAAc,EAAE;gBACjD;YACF;YACAC,YAAY;QACd;IACF;IAEAhC,QAAQE,IAAI,CAAC;QACXK,QAAQ;QACRG,SAAS;YACPuB,OAAOpC,IAAIQ,aAAa;YACxBkB,UAAU1B,IAAI0B,QAAQ;YACtBjB,aAAaT,IAAIS,WAAW;YAC5B4B,cAAcrC,IAAIqC,YAAY;YAC9BnC;YACAD;QACF;IACF;IAEA,OAAOE;AACT","ignoreList":[0]}
+4
View File
@@ -0,0 +1,4 @@
export declare function getGlobalImportError(): string;
export declare function getGlobalModuleImportError(): string;
export declare function getLocalModuleImportError(): string;
export declare function getCustomDocumentError(): string;
+45
View File
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getCustomDocumentError: null,
getGlobalImportError: null,
getGlobalModuleImportError: null,
getLocalModuleImportError: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getCustomDocumentError: function() {
return getCustomDocumentError;
},
getGlobalImportError: function() {
return getGlobalImportError;
},
getGlobalModuleImportError: function() {
return getGlobalModuleImportError;
},
getLocalModuleImportError: function() {
return getLocalModuleImportError;
}
});
const _picocolors = require("../../../../../lib/picocolors");
function getGlobalImportError() {
return `Global CSS ${(0, _picocolors.bold)('cannot')} be imported from files other than your ${(0, _picocolors.bold)('Custom <App>')}. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to ${(0, _picocolors.cyan)('pages/_app.js')}. Or convert the import to Component-Level CSS (CSS Modules).\nRead more: https://nextjs.org/docs/messages/css-global`;
}
function getGlobalModuleImportError() {
return `Global CSS ${(0, _picocolors.bold)('cannot')} be imported from within ${(0, _picocolors.bold)('node_modules')}.\nRead more: https://nextjs.org/docs/messages/css-npm`;
}
function getLocalModuleImportError() {
return `CSS Modules ${(0, _picocolors.bold)('cannot')} be imported from within ${(0, _picocolors.bold)('node_modules')}.\nRead more: https://nextjs.org/docs/messages/css-modules-npm`;
}
function getCustomDocumentError() {
return `CSS ${(0, _picocolors.bold)('cannot')} be imported within ${(0, _picocolors.cyan)('pages/_document.js')}. Please move global styles to ${(0, _picocolors.cyan)('pages/_app.js')}.`;
}
//# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/build/webpack/config/blocks/css/messages.ts"],"sourcesContent":["import { bold, cyan } from '../../../../../lib/picocolors'\n\nexport function getGlobalImportError() {\n return `Global CSS ${bold(\n 'cannot'\n )} be imported from files other than your ${bold(\n 'Custom <App>'\n )}. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to ${cyan(\n 'pages/_app.js'\n )}. Or convert the import to Component-Level CSS (CSS Modules).\\nRead more: https://nextjs.org/docs/messages/css-global`\n}\n\nexport function getGlobalModuleImportError() {\n return `Global CSS ${bold('cannot')} be imported from within ${bold(\n 'node_modules'\n )}.\\nRead more: https://nextjs.org/docs/messages/css-npm`\n}\n\nexport function getLocalModuleImportError() {\n return `CSS Modules ${bold('cannot')} be imported from within ${bold(\n 'node_modules'\n )}.\\nRead more: https://nextjs.org/docs/messages/css-modules-npm`\n}\n\nexport function getCustomDocumentError() {\n return `CSS ${bold('cannot')} be imported within ${cyan(\n 'pages/_document.js'\n )}. Please move global styles to ${cyan('pages/_app.js')}.`\n}\n"],"names":["getCustomDocumentError","getGlobalImportError","getGlobalModuleImportError","getLocalModuleImportError","bold","cyan"],"mappings":";;;;;;;;;;;;;;;;;IAwBgBA,sBAAsB;eAAtBA;;IAtBAC,oBAAoB;eAApBA;;IAUAC,0BAA0B;eAA1BA;;IAMAC,yBAAyB;eAAzBA;;;4BAlBW;AAEpB,SAASF;IACd,OAAO,CAAC,WAAW,EAAEG,IAAAA,gBAAI,EACvB,UACA,wCAAwC,EAAEA,IAAAA,gBAAI,EAC9C,gBACA,qHAAqH,EAAEC,IAAAA,gBAAI,EAC3H,iBACA,qHAAqH,CAAC;AAC1H;AAEO,SAASH;IACd,OAAO,CAAC,WAAW,EAAEE,IAAAA,gBAAI,EAAC,UAAU,yBAAyB,EAAEA,IAAAA,gBAAI,EACjE,gBACA,sDAAsD,CAAC;AAC3D;AAEO,SAASD;IACd,OAAO,CAAC,YAAY,EAAEC,IAAAA,gBAAI,EAAC,UAAU,yBAAyB,EAAEA,IAAAA,gBAAI,EAClE,gBACA,8DAA8D,CAAC;AACnE;AAEO,SAASJ;IACd,OAAO,CAAC,IAAI,EAAEI,IAAAA,gBAAI,EAAC,UAAU,oBAAoB,EAAEC,IAAAA,gBAAI,EACrD,sBACA,+BAA+B,EAAEA,IAAAA,gBAAI,EAAC,iBAAiB,CAAC,CAAC;AAC7D","ignoreList":[0]}
+1
View File
@@ -0,0 +1 @@
export declare function getPostCssPlugins(dir: string, supportedBrowsers: string[] | undefined, disablePostcssPresetEnv?: boolean, useLightningcss?: boolean): Promise<import('postcss').AcceptedPlugin[]>;
+190
View File
@@ -0,0 +1,190 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getPostCssPlugins", {
enumerable: true,
get: function() {
return getPostCssPlugins;
}
});
const _picocolors = require("../../../../../lib/picocolors");
const _findconfig = require("../../../../../lib/find-config");
const genericErrorText = 'Malformed PostCSS Configuration';
function getError_NullConfig(pluginName) {
return `${(0, _picocolors.red)((0, _picocolors.bold)('Error'))}: Your PostCSS configuration for '${pluginName}' cannot have ${(0, _picocolors.bold)('null')} configuration.\nTo disable '${pluginName}', pass ${(0, _picocolors.bold)('false')}, otherwise, pass ${(0, _picocolors.bold)('true')} or a configuration object.`;
}
function isIgnoredPlugin(pluginPath) {
const ignoredRegex = /(?:^|[\\/])(postcss-modules-values|postcss-modules-scope|postcss-modules-extract-imports|postcss-modules-local-by-default|postcss-modules)(?:[\\/]|$)/i;
const match = ignoredRegex.exec(pluginPath);
if (match == null) {
return false;
}
const plugin = match.pop();
console.warn(`${(0, _picocolors.yellow)((0, _picocolors.bold)('Warning'))}: Please remove the ${(0, _picocolors.underline)(plugin)} plugin from your PostCSS configuration. ` + `This plugin is automatically configured by Next.js.\n` + 'Read more: https://nextjs.org/docs/messages/postcss-ignored-plugin');
return true;
}
const createLazyPostCssPlugin = (fn)=>{
let result = undefined;
const plugin = (...args)=>{
if (result === undefined) result = fn();
if (result.postcss === true) {
return result(...args);
} else if (result.postcss) {
return result.postcss;
}
return result;
};
plugin.postcss = true;
return plugin;
};
async function loadPlugin(dir, pluginName, options) {
if (options === false || isIgnoredPlugin(pluginName)) {
return false;
}
if (options == null) {
console.error(getError_NullConfig(pluginName));
throw Object.defineProperty(new Error(genericErrorText), "__NEXT_ERROR_CODE", {
value: "E1036",
enumerable: false,
configurable: true
});
}
const pluginPath = require.resolve(pluginName, {
paths: [
dir
]
});
if (isIgnoredPlugin(pluginPath)) {
return false;
} else if (options === true) {
return createLazyPostCssPlugin(()=>require(pluginPath));
} else {
if (typeof options === 'object' && Object.keys(options).length === 0) {
return createLazyPostCssPlugin(()=>require(pluginPath));
}
return createLazyPostCssPlugin(()=>require(pluginPath)(options));
}
}
function getDefaultPlugins(supportedBrowsers, disablePostcssPresetEnv) {
return [
require.resolve('next/dist/compiled/postcss-flexbugs-fixes'),
disablePostcssPresetEnv ? false : [
require.resolve('next/dist/compiled/postcss-preset-env'),
{
browsers: supportedBrowsers ?? [
'defaults'
],
autoprefixer: {
// Disable legacy flexbox support
flexbox: 'no-2009'
},
// Enable CSS features that have shipped to the
// web platform, i.e. in 2+ browsers unflagged.
stage: 3,
features: {
'custom-properties': false
}
}
]
].filter(Boolean);
}
async function getPostCssPlugins(dir, supportedBrowsers, disablePostcssPresetEnv = false, useLightningcss = false) {
let config = await (0, _findconfig.findConfig)(dir, 'postcss');
if (config == null) {
config = {
plugins: useLightningcss ? [] : getDefaultPlugins(supportedBrowsers, disablePostcssPresetEnv)
};
}
if (typeof config === 'function') {
throw Object.defineProperty(new Error(`Your custom PostCSS configuration may not export a function. Please export a plain object instead.\n` + 'Read more: https://nextjs.org/docs/messages/postcss-function'), "__NEXT_ERROR_CODE", {
value: "E323",
enumerable: false,
configurable: true
});
}
// Warn user about configuration keys which are not respected
const invalidKey = Object.keys(config).find((key)=>key !== 'plugins');
if (invalidKey) {
console.warn(`${(0, _picocolors.yellow)((0, _picocolors.bold)('Warning'))}: Your PostCSS configuration defines a field which is not supported (\`${invalidKey}\`). ` + `Please remove this configuration value.`);
}
// Enforce the user provided plugins if the configuration file is present
let plugins = config.plugins;
if (plugins == null || typeof plugins !== 'object') {
throw Object.defineProperty(new Error(`Your custom PostCSS configuration must export a \`plugins\` key.`), "__NEXT_ERROR_CODE", {
value: "E347",
enumerable: false,
configurable: true
});
}
if (!Array.isArray(plugins)) {
// Capture variable so TypeScript is happy
const pc = plugins;
plugins = Object.keys(plugins).reduce((acc, curr)=>{
const p = pc[curr];
if (typeof p === 'undefined') {
console.error(getError_NullConfig(curr));
throw Object.defineProperty(new Error(genericErrorText), "__NEXT_ERROR_CODE", {
value: "E1036",
enumerable: false,
configurable: true
});
}
acc.push([
curr,
p
]);
return acc;
}, []);
}
const parsed = [];
plugins.forEach((plugin)=>{
if (plugin == null) {
console.warn(`${(0, _picocolors.yellow)((0, _picocolors.bold)('Warning'))}: A ${(0, _picocolors.bold)('null')} PostCSS plugin was provided. This entry will be ignored.`);
} else if (typeof plugin === 'string') {
parsed.push([
plugin,
true
]);
} else if (Array.isArray(plugin)) {
const pluginName = plugin[0];
const pluginConfig = plugin[1];
if (typeof pluginName === 'string' && (typeof pluginConfig === 'boolean' || typeof pluginConfig === 'object' || typeof pluginConfig === 'string')) {
parsed.push([
pluginName,
pluginConfig
]);
} else {
if (typeof pluginName !== 'string') {
console.error(`${(0, _picocolors.red)((0, _picocolors.bold)('Error'))}: A PostCSS Plugin must be provided as a ${(0, _picocolors.bold)('string')}. Instead, we got: '${pluginName}'.\n` + 'Read more: https://nextjs.org/docs/messages/postcss-shape');
} else {
console.error(`${(0, _picocolors.red)((0, _picocolors.bold)('Error'))}: A PostCSS Plugin was passed as an array but did not provide its configuration ('${pluginName}').\n` + 'Read more: https://nextjs.org/docs/messages/postcss-shape');
}
throw Object.defineProperty(new Error(genericErrorText), "__NEXT_ERROR_CODE", {
value: "E1036",
enumerable: false,
configurable: true
});
}
} else if (typeof plugin === 'function') {
console.error(`${(0, _picocolors.red)((0, _picocolors.bold)('Error'))}: A PostCSS Plugin was passed as a function using require(), but it must be provided as a ${(0, _picocolors.bold)('string')}.\nRead more: https://nextjs.org/docs/messages/postcss-shape`);
throw Object.defineProperty(new Error(genericErrorText), "__NEXT_ERROR_CODE", {
value: "E1036",
enumerable: false,
configurable: true
});
} else {
console.error(`${(0, _picocolors.red)((0, _picocolors.bold)('Error'))}: An unknown PostCSS plugin was provided (${plugin}).\n` + 'Read more: https://nextjs.org/docs/messages/postcss-shape');
throw Object.defineProperty(new Error(genericErrorText), "__NEXT_ERROR_CODE", {
value: "E1036",
enumerable: false,
configurable: true
});
}
});
const resolved = await Promise.all(parsed.map((p)=>loadPlugin(dir, p[0], p[1])));
const filtered = resolved.filter(Boolean);
return filtered;
}
//# sourceMappingURL=plugins.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { ConfigurationContext } from '../../utils';
export declare const images: import("lodash").CurriedFunction2<ConfigurationContext, webpack.Configuration, Promise<webpack.Configuration>>;
+42
View File
@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "images", {
enumerable: true,
get: function() {
return images;
}
});
const _lodashcurry = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/lodash.curry"));
const _webpackconfig = require("../../../../webpack-config");
const _helpers = require("../../helpers");
const _utils = require("../../utils");
const _messages = require("./messages");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const images = (0, _lodashcurry.default)(async function images(_ctx, config) {
const fns = [
(0, _helpers.loader)({
oneOf: [
{
test: _webpackconfig.nextImageLoaderRegex,
use: {
loader: 'error-loader',
options: {
reason: (0, _messages.getCustomDocumentImageError)()
}
},
issuer: /pages[\\/]_document\./
}
]
})
];
const fn = (0, _utils.pipe)(...fns);
return fn(config);
});
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/build/webpack/config/blocks/images/index.ts"],"sourcesContent":["import curry from 'next/dist/compiled/lodash.curry'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { nextImageLoaderRegex } from '../../../../webpack-config'\nimport { loader } from '../../helpers'\nimport { pipe } from '../../utils'\nimport type { ConfigurationContext, ConfigurationFn } from '../../utils'\nimport { getCustomDocumentImageError } from './messages'\n\nexport const images = curry(async function images(\n _ctx: ConfigurationContext,\n config: webpack.Configuration\n) {\n const fns: ConfigurationFn[] = [\n loader({\n oneOf: [\n {\n test: nextImageLoaderRegex,\n use: {\n loader: 'error-loader',\n options: {\n reason: getCustomDocumentImageError(),\n },\n },\n issuer: /pages[\\\\/]_document\\./,\n },\n ],\n }),\n ]\n\n const fn = pipe(...fns)\n return fn(config)\n})\n"],"names":["images","curry","_ctx","config","fns","loader","oneOf","test","nextImageLoaderRegex","use","options","reason","getCustomDocumentImageError","issuer","fn","pipe"],"mappings":";;;;+BAQaA;;;eAAAA;;;oEARK;+BAEmB;yBACd;uBACF;0BAEuB;;;;;;AAErC,MAAMA,SAASC,IAAAA,oBAAK,EAAC,eAAeD,OACzCE,IAA0B,EAC1BC,MAA6B;IAE7B,MAAMC,MAAyB;QAC7BC,IAAAA,eAAM,EAAC;YACLC,OAAO;gBACL;oBACEC,MAAMC,mCAAoB;oBAC1BC,KAAK;wBACHJ,QAAQ;wBACRK,SAAS;4BACPC,QAAQC,IAAAA,qCAA2B;wBACrC;oBACF;oBACAC,QAAQ;gBACV;aACD;QACH;KACD;IAED,MAAMC,KAAKC,IAAAA,WAAI,KAAIX;IACnB,OAAOU,GAAGX;AACZ","ignoreList":[0]}
@@ -0,0 +1 @@
export declare function getCustomDocumentImageError(): string;
+16
View File
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getCustomDocumentImageError", {
enumerable: true,
get: function() {
return getCustomDocumentImageError;
}
});
const _picocolors = require("../../../../../lib/picocolors");
function getCustomDocumentImageError() {
return `Images ${(0, _picocolors.bold)('cannot')} be imported within ${(0, _picocolors.cyan)('pages/_document.js')}. Please move image imports that need to be displayed on every page into ${(0, _picocolors.cyan)('pages/_app.js')}.\nRead more: https://nextjs.org/docs/messages/custom-document-image-import`;
}
//# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/build/webpack/config/blocks/images/messages.ts"],"sourcesContent":["import { bold, cyan } from '../../../../../lib/picocolors'\n\nexport function getCustomDocumentImageError() {\n return `Images ${bold('cannot')} be imported within ${cyan(\n 'pages/_document.js'\n )}. Please move image imports that need to be displayed on every page into ${cyan(\n 'pages/_app.js'\n )}.\\nRead more: https://nextjs.org/docs/messages/custom-document-image-import`\n}\n"],"names":["getCustomDocumentImageError","bold","cyan"],"mappings":";;;;+BAEgBA;;;eAAAA;;;4BAFW;AAEpB,SAASA;IACd,OAAO,CAAC,OAAO,EAAEC,IAAAA,gBAAI,EAAC,UAAU,oBAAoB,EAAEC,IAAAA,gBAAI,EACxD,sBACA,yEAAyE,EAAEA,IAAAA,gBAAI,EAC/E,iBACA,2EAA2E,CAAC;AAChF","ignoreList":[0]}
+4
View File
@@ -0,0 +1,4 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
export declare const loader: import("lodash").CurriedFunction2<webpack.RuleSetRule, webpack.Configuration, webpack.Configuration>;
export declare const unshiftLoader: import("lodash").CurriedFunction2<webpack.RuleSetRule, webpack.Configuration, webpack.Configuration>;
export declare const plugin: import("lodash").CurriedFunction2<webpack.WebpackPluginInstance, webpack.Configuration, webpack.Configuration>;
+78
View File
@@ -0,0 +1,78 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
loader: null,
plugin: null,
unshiftLoader: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
loader: function() {
return loader;
},
plugin: function() {
return plugin;
},
unshiftLoader: function() {
return unshiftLoader;
}
});
const _lodashcurry = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/lodash.curry"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const loader = (0, _lodashcurry.default)(function loader(rule, config) {
var _config_module_rules;
if (!config.module) {
config.module = {
rules: []
};
}
if (rule.oneOf) {
var _config_module_rules1;
const existing = (_config_module_rules1 = config.module.rules) == null ? void 0 : _config_module_rules1.find((arrayRule)=>arrayRule && typeof arrayRule === 'object' && arrayRule.oneOf);
if (existing && typeof existing === 'object') {
existing.oneOf.push(...rule.oneOf);
return config;
}
}
(_config_module_rules = config.module.rules) == null ? void 0 : _config_module_rules.push(rule);
return config;
});
const unshiftLoader = (0, _lodashcurry.default)(function unshiftLoader(rule, config) {
var _config_module_rules;
if (!config.module) {
config.module = {
rules: []
};
}
if (rule.oneOf) {
var _config_module_rules1;
const existing = (_config_module_rules1 = config.module.rules) == null ? void 0 : _config_module_rules1.find((arrayRule)=>arrayRule && typeof arrayRule === 'object' && arrayRule.oneOf);
if (existing && typeof existing === 'object') {
var _existing_oneOf;
(_existing_oneOf = existing.oneOf) == null ? void 0 : _existing_oneOf.unshift(...rule.oneOf);
return config;
}
}
(_config_module_rules = config.module.rules) == null ? void 0 : _config_module_rules.unshift(rule);
return config;
});
const plugin = (0, _lodashcurry.default)(function plugin(p, config) {
if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(p);
return config;
});
//# sourceMappingURL=helpers.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/build/webpack/config/helpers.ts"],"sourcesContent":["import curry from 'next/dist/compiled/lodash.curry'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\n\nexport const loader = curry(function loader(\n rule: webpack.RuleSetRule,\n config: webpack.Configuration\n) {\n if (!config.module) {\n config.module = { rules: [] }\n }\n\n if (rule.oneOf) {\n const existing = config.module.rules?.find(\n (arrayRule) =>\n arrayRule && typeof arrayRule === 'object' && arrayRule.oneOf\n )\n if (existing && typeof existing === 'object') {\n existing.oneOf!.push(...rule.oneOf)\n return config\n }\n }\n\n config.module.rules?.push(rule)\n return config\n})\n\nexport const unshiftLoader = curry(function unshiftLoader(\n rule: webpack.RuleSetRule,\n config: webpack.Configuration\n) {\n if (!config.module) {\n config.module = { rules: [] }\n }\n\n if (rule.oneOf) {\n const existing = config.module.rules?.find(\n (arrayRule) =>\n arrayRule && typeof arrayRule === 'object' && arrayRule.oneOf\n )\n if (existing && typeof existing === 'object') {\n existing.oneOf?.unshift(...rule.oneOf)\n return config\n }\n }\n\n config.module.rules?.unshift(rule)\n return config\n})\n\nexport const plugin = curry(function plugin(\n p: webpack.WebpackPluginInstance,\n config: webpack.Configuration\n) {\n if (!config.plugins) {\n config.plugins = []\n }\n config.plugins.push(p)\n return config\n})\n"],"names":["loader","plugin","unshiftLoader","curry","rule","config","module","rules","oneOf","existing","find","arrayRule","push","unshift","p","plugins"],"mappings":";;;;;;;;;;;;;;;;IAGaA,MAAM;eAANA;;IA8CAC,MAAM;eAANA;;IAvBAC,aAAa;eAAbA;;;oEA1BK;;;;;;AAGX,MAAMF,SAASG,IAAAA,oBAAK,EAAC,SAASH,OACnCI,IAAyB,EACzBC,MAA6B;QAiB7BA;IAfA,IAAI,CAACA,OAAOC,MAAM,EAAE;QAClBD,OAAOC,MAAM,GAAG;YAAEC,OAAO,EAAE;QAAC;IAC9B;IAEA,IAAIH,KAAKI,KAAK,EAAE;YACGH;QAAjB,MAAMI,YAAWJ,wBAAAA,OAAOC,MAAM,CAACC,KAAK,qBAAnBF,sBAAqBK,IAAI,CACxC,CAACC,YACCA,aAAa,OAAOA,cAAc,YAAYA,UAAUH,KAAK;QAEjE,IAAIC,YAAY,OAAOA,aAAa,UAAU;YAC5CA,SAASD,KAAK,CAAEI,IAAI,IAAIR,KAAKI,KAAK;YAClC,OAAOH;QACT;IACF;KAEAA,uBAAAA,OAAOC,MAAM,CAACC,KAAK,qBAAnBF,qBAAqBO,IAAI,CAACR;IAC1B,OAAOC;AACT;AAEO,MAAMH,gBAAgBC,IAAAA,oBAAK,EAAC,SAASD,cAC1CE,IAAyB,EACzBC,MAA6B;QAiB7BA;IAfA,IAAI,CAACA,OAAOC,MAAM,EAAE;QAClBD,OAAOC,MAAM,GAAG;YAAEC,OAAO,EAAE;QAAC;IAC9B;IAEA,IAAIH,KAAKI,KAAK,EAAE;YACGH;QAAjB,MAAMI,YAAWJ,wBAAAA,OAAOC,MAAM,CAACC,KAAK,qBAAnBF,sBAAqBK,IAAI,CACxC,CAACC,YACCA,aAAa,OAAOA,cAAc,YAAYA,UAAUH,KAAK;QAEjE,IAAIC,YAAY,OAAOA,aAAa,UAAU;gBAC5CA;aAAAA,kBAAAA,SAASD,KAAK,qBAAdC,gBAAgBI,OAAO,IAAIT,KAAKI,KAAK;YACrC,OAAOH;QACT;IACF;KAEAA,uBAAAA,OAAOC,MAAM,CAACC,KAAK,qBAAnBF,qBAAqBQ,OAAO,CAACT;IAC7B,OAAOC;AACT;AAEO,MAAMJ,SAASE,IAAAA,oBAAK,EAAC,SAASF,OACnCa,CAAgC,EAChCT,MAA6B;IAE7B,IAAI,CAACA,OAAOU,OAAO,EAAE;QACnBV,OAAOU,OAAO,GAAG,EAAE;IACrB;IACAV,OAAOU,OAAO,CAACH,IAAI,CAACE;IACpB,OAAOT;AACT","ignoreList":[0]}
+21
View File
@@ -0,0 +1,21 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { NextConfigComplete } from '../../../server/config-shared';
export declare function buildConfiguration(config: webpack.Configuration, { hasAppDir, supportedBrowsers, rootDirectory, customAppFile, isDevelopment, isServer, isEdgeRuntime, targetWeb, assetPrefix, sassOptions, productionBrowserSourceMaps, future, transpilePackages, experimental, disableStaticImages, serverSourceMaps, deploymentId, }: {
hasAppDir: boolean;
supportedBrowsers: string[] | undefined;
rootDirectory: string;
customAppFile: RegExp | undefined;
isDevelopment: boolean;
isServer: boolean;
isEdgeRuntime: boolean;
targetWeb: boolean;
assetPrefix: string;
sassOptions: any;
productionBrowserSourceMaps: boolean;
transpilePackages: NextConfigComplete['transpilePackages'];
future: NextConfigComplete['future'];
experimental: NextConfigComplete['experimental'];
disableStaticImages: NextConfigComplete['images']['disableStaticImages'];
serverSourceMaps: NextConfigComplete['experimental']['serverSourceMaps'];
deploymentId?: string;
}): Promise<webpack.Configuration>;
+47
View File
@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "buildConfiguration", {
enumerable: true,
get: function() {
return buildConfiguration;
}
});
const _base = require("./blocks/base");
const _css = require("./blocks/css");
const _images = require("./blocks/images");
const _utils = require("./utils");
async function buildConfiguration(config, { hasAppDir, supportedBrowsers, rootDirectory, customAppFile, isDevelopment, isServer, isEdgeRuntime, targetWeb, assetPrefix, sassOptions, productionBrowserSourceMaps, future, transpilePackages, experimental, disableStaticImages, serverSourceMaps, deploymentId }) {
const ctx = {
hasAppDir,
supportedBrowsers,
rootDirectory,
customAppFile,
isDevelopment,
isProduction: !isDevelopment,
isServer,
isEdgeRuntime,
isClient: !isServer,
targetWeb,
assetPrefix: assetPrefix ? assetPrefix.endsWith('/') ? assetPrefix.slice(0, -1) : assetPrefix : '',
sassOptions,
productionBrowserSourceMaps,
transpilePackages,
future,
experimental,
serverSourceMaps: serverSourceMaps ?? false,
deploymentId
};
let fns = [
(0, _base.base)(ctx),
(0, _css.css)(ctx)
];
if (!disableStaticImages) {
fns.push((0, _images.images)(ctx));
}
const fn = (0, _utils.pipe)(...fns);
return fn(config);
}
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/build/webpack/config/index.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport type { NextConfigComplete } from '../../../server/config-shared'\nimport type { ConfigurationContext } from './utils'\n\nimport { base } from './blocks/base'\nimport { css } from './blocks/css'\nimport { images } from './blocks/images'\nimport { pipe } from './utils'\n\nexport async function buildConfiguration(\n config: webpack.Configuration,\n {\n hasAppDir,\n supportedBrowsers,\n rootDirectory,\n customAppFile,\n isDevelopment,\n isServer,\n isEdgeRuntime,\n targetWeb,\n assetPrefix,\n sassOptions,\n productionBrowserSourceMaps,\n future,\n transpilePackages,\n experimental,\n disableStaticImages,\n serverSourceMaps,\n deploymentId,\n }: {\n hasAppDir: boolean\n supportedBrowsers: string[] | undefined\n rootDirectory: string\n customAppFile: RegExp | undefined\n isDevelopment: boolean\n isServer: boolean\n isEdgeRuntime: boolean\n targetWeb: boolean\n assetPrefix: string\n sassOptions: any\n productionBrowserSourceMaps: boolean\n transpilePackages: NextConfigComplete['transpilePackages']\n // @ts-expect-error TODO: remove any\n future: NextConfigComplete['future']\n experimental: NextConfigComplete['experimental']\n disableStaticImages: NextConfigComplete['images']['disableStaticImages']\n serverSourceMaps: NextConfigComplete['experimental']['serverSourceMaps']\n deploymentId?: string\n }\n): Promise<webpack.Configuration> {\n const ctx: ConfigurationContext = {\n hasAppDir,\n supportedBrowsers,\n rootDirectory,\n customAppFile,\n isDevelopment,\n isProduction: !isDevelopment,\n isServer,\n isEdgeRuntime,\n isClient: !isServer,\n targetWeb,\n assetPrefix: assetPrefix\n ? assetPrefix.endsWith('/')\n ? assetPrefix.slice(0, -1)\n : assetPrefix\n : '',\n sassOptions,\n productionBrowserSourceMaps,\n transpilePackages,\n future,\n experimental,\n serverSourceMaps: serverSourceMaps ?? false,\n deploymentId,\n }\n\n let fns = [base(ctx), css(ctx)]\n if (!disableStaticImages) {\n fns.push(images(ctx))\n }\n const fn = pipe(...fns)\n return fn(config)\n}\n"],"names":["buildConfiguration","config","hasAppDir","supportedBrowsers","rootDirectory","customAppFile","isDevelopment","isServer","isEdgeRuntime","targetWeb","assetPrefix","sassOptions","productionBrowserSourceMaps","future","transpilePackages","experimental","disableStaticImages","serverSourceMaps","deploymentId","ctx","isProduction","isClient","endsWith","slice","fns","base","css","push","images","fn","pipe"],"mappings":";;;;+BASsBA;;;eAAAA;;;sBALD;qBACD;wBACG;uBACF;AAEd,eAAeA,mBACpBC,MAA6B,EAC7B,EACEC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,2BAA2B,EAC3BC,MAAM,EACNC,iBAAiB,EACjBC,YAAY,EACZC,mBAAmB,EACnBC,gBAAgB,EAChBC,YAAY,EAoBb;IAED,MAAMC,MAA4B;QAChCjB;QACAC;QACAC;QACAC;QACAC;QACAc,cAAc,CAACd;QACfC;QACAC;QACAa,UAAU,CAACd;QACXE;QACAC,aAAaA,cACTA,YAAYY,QAAQ,CAAC,OACnBZ,YAAYa,KAAK,CAAC,GAAG,CAAC,KACtBb,cACF;QACJC;QACAC;QACAE;QACAD;QACAE;QACAE,kBAAkBA,oBAAoB;QACtCC;IACF;IAEA,IAAIM,MAAM;QAACC,IAAAA,UAAI,EAACN;QAAMO,IAAAA,QAAG,EAACP;KAAK;IAC/B,IAAI,CAACH,qBAAqB;QACxBQ,IAAIG,IAAI,CAACC,IAAAA,cAAM,EAACT;IAClB;IACA,MAAMU,KAAKC,IAAAA,WAAI,KAAIN;IACnB,OAAOK,GAAG5B;AACZ","ignoreList":[0]}
+25
View File
@@ -0,0 +1,25 @@
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { NextConfigComplete } from '../../../server/config-shared';
export type ConfigurationContext = {
hasAppDir: boolean;
isAppDir?: boolean;
supportedBrowsers: string[] | undefined;
rootDirectory: string;
customAppFile: RegExp | undefined;
isDevelopment: boolean;
isProduction: boolean;
isServer: boolean;
isClient: boolean;
isEdgeRuntime: boolean;
targetWeb: boolean;
assetPrefix: string;
sassOptions: any;
productionBrowserSourceMaps: boolean;
serverSourceMaps: boolean;
transpilePackages: NextConfigComplete['transpilePackages'];
future: NextConfigComplete['future'];
experimental: NextConfigComplete['experimental'];
deploymentId?: string;
};
export type ConfigurationFn = (a: webpack.Configuration) => webpack.Configuration;
export declare const pipe: <R>(...fns: Array<(a: R) => R | Promise<R>>) => (param: R) => R | Promise<R>;
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "pipe", {
enumerable: true,
get: function() {
return pipe;
}
});
const pipe = (...fns)=>(param)=>fns.reduce(async (result, next)=>next(await result), param);
//# sourceMappingURL=utils.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/build/webpack/config/utils.ts"],"sourcesContent":["import type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport type { NextConfigComplete } from '../../../server/config-shared'\n\nexport type ConfigurationContext = {\n // If the `appDir` feature is enabled\n hasAppDir: boolean\n // If the current rule matches a resource in the app layer\n isAppDir?: boolean\n supportedBrowsers: string[] | undefined\n rootDirectory: string\n customAppFile: RegExp | undefined\n\n isDevelopment: boolean\n isProduction: boolean\n\n isServer: boolean\n isClient: boolean\n isEdgeRuntime: boolean\n targetWeb: boolean\n\n assetPrefix: string\n\n sassOptions: any\n productionBrowserSourceMaps: boolean\n serverSourceMaps: boolean\n\n transpilePackages: NextConfigComplete['transpilePackages']\n\n // @ts-expect-error TODO: remove any\n future: NextConfigComplete['future']\n experimental: NextConfigComplete['experimental']\n\n deploymentId?: string\n}\n\nexport type ConfigurationFn = (\n a: webpack.Configuration\n) => webpack.Configuration\n\nexport const pipe =\n <R>(...fns: Array<(a: R) => R | Promise<R>>) =>\n (param: R) =>\n fns.reduce(\n async (result: R | Promise<R>, next) => next(await result),\n param\n )\n"],"names":["pipe","fns","param","reduce","result","next"],"mappings":";;;;+BAuCaA;;;eAAAA;;;AAAN,MAAMA,OACX,CAAI,GAAGC,MACP,CAACC,QACCD,IAAIE,MAAM,CACR,OAAOC,QAAwBC,OAASA,KAAK,MAAMD,SACnDF","ignoreList":[0]}