create project

This commit is contained in:
ismailsosic
2022-12-27 12:05:56 +01:00
parent 2a33a2d3de
commit cd2143287c
16035 changed files with 2489703 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import curry from "next/dist/compiled/lodash.curry";
import { COMPILER_NAMES } from "../../../../shared/lib/constants";
export const base = curry(function base(ctx, config) {
config.mode = ctx.isDevelopment ? "development" : "production";
config.name = ctx.isServer ? ctx.isEdgeRuntime ? COMPILER_NAMES.edgeServer : COMPILER_NAMES.server : COMPILER_NAMES.client;
// @ts-ignore TODO webpack 5 typings
config.target = !ctx.targetWeb ? "node12.22" : ctx.isEdgeRuntime ? [
"web",
"es6"
] : [
"web",
"es5"
];
// https://webpack.js.org/configuration/devtool/#development
if (ctx.isDevelopment) {
if (process.env.__NEXT_TEST_MODE && !process.env.__NEXT_TEST_WITH_DEVTOOL) {
config.devtool = false;
} else {
// `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 || // Enable browser sourcemaps:
(ctx.productionBrowserSourceMaps && ctx.isClient)) {
config.devtool = "source-map";
} else {
config.devtool = false;
}
}
if (!config.module) {
config.module = {
rules: []
};
}
// TODO: add codemod for "Should not import the named export" with JSON files
// config.module.strictExportPresence = !isWebpack5
return config;
});
//# sourceMappingURL=base.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../build/webpack/config/blocks/base.ts"],"names":["curry","COMPILER_NAMES","base","ctx","config","mode","isDevelopment","name","isServer","isEdgeRuntime","edgeServer","server","client","target","targetWeb","process","env","__NEXT_TEST_MODE","__NEXT_TEST_WITH_DEVTOOL","devtool","productionBrowserSourceMaps","isClient","module","rules"],"mappings":"AAAA,OAAOA,KAAK,MAAM,iCAAiC,CAAA;AAEnD,SAASC,cAAc,QAAQ,kCAAkC,CAAA;AAGjE,OAAO,MAAMC,IAAI,GAAGF,KAAK,CAAC,SAASE,IAAI,CACrCC,GAAyB,EACzBC,MAA6B,EAC7B;IACAA,MAAM,CAACC,IAAI,GAAGF,GAAG,CAACG,aAAa,GAAG,aAAa,GAAG,YAAY;IAC9DF,MAAM,CAACG,IAAI,GAAGJ,GAAG,CAACK,QAAQ,GACtBL,GAAG,CAACM,aAAa,GACfR,cAAc,CAACS,UAAU,GACzBT,cAAc,CAACU,MAAM,GACvBV,cAAc,CAACW,MAAM;IAEzB,oCAAoC;IACpCR,MAAM,CAACS,MAAM,GAAG,CAACV,GAAG,CAACW,SAAS,GAC1B,WAAW,GACXX,GAAG,CAACM,aAAa,GACjB;QAAC,KAAK;QAAE,KAAK;KAAC,GACd;QAAC,KAAK;QAAE,KAAK;KAAC;IAElB,4DAA4D;IAC5D,IAAIN,GAAG,CAACG,aAAa,EAAE;QACrB,IAAIS,OAAO,CAACC,GAAG,CAACC,gBAAgB,IAAI,CAACF,OAAO,CAACC,GAAG,CAACE,wBAAwB,EAAE;YACzEd,MAAM,CAACe,OAAO,GAAG,KAAK;SACvB,MAAM;YACL,+DAA+D;YAC/D,kEAAkE;YAClE,mEAAmE;YACnE,uDAAuD;YACvDf,MAAM,CAACe,OAAO,GAAG,iBAAiB;SACnC;KACF,MAAM;QACL,IACEhB,GAAG,CAACM,aAAa,IACjB,6BAA6B;QAC7B,CAACN,GAAG,CAACiB,2BAA2B,IAAIjB,GAAG,CAACkB,QAAQ,CAAC,EACjD;YACAjB,MAAM,CAACe,OAAO,GAAG,YAAY;SAC9B,MAAM;YACLf,MAAM,CAACe,OAAO,GAAG,KAAK;SACvB;KACF;IAED,IAAI,CAACf,MAAM,CAACkB,MAAM,EAAE;QAClBlB,MAAM,CAACkB,MAAM,GAAG;YAAEC,KAAK,EAAE,EAAE;SAAE;KAC9B;IAED,6EAA6E;IAC7E,mDAAmD;IAEnD,OAAOnB,MAAM,CAAA;CACd,CAAC,CAAA"}

View File

@@ -0,0 +1,474 @@
import path from "path";
import curry from "next/dist/compiled/lodash.curry";
import { loader, plugin } from "../../helpers";
import { pipe } from "../../utils";
import { getCssModuleLoader, getGlobalCssLoader } from "./loaders";
import { getNextFontLoader } from "./loaders/next-font";
import { getCustomDocumentError, getGlobalImportError, getGlobalModuleImportError, getLocalModuleImportError } from "./messages";
import { getPostCssPlugins } from "./plugins";
import { nonNullable } from "../../../../../lib/non-nullable";
import { WEBPACK_LAYERS } from "../../../../../lib/constants";
// RegExps for all Style Sheet variants
export 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)$/;
/**
* 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;
export async function lazyPostCSS(rootDirectory, supportedBrowsers, disablePostcssPresetEnv) {
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(css1, processOpts, pluginOpts) {
return postcss([
creator(pluginOpts)
]).process(css1, 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 getPostCssPlugins(rootDirectory, supportedBrowsers, disablePostcssPresetEnv);
return {
postcss,
postcssWithPlugins: postcss(postCssPlugins)
};
})();
}
return postcssInstancePromise;
}
export const css = curry(async function css(ctx, config) {
const { prependData: sassPrependData , additionalData: sassAdditionalData , ...sassOptions } = ctx.sassOptions;
const lazyPostCSSInitializer = ()=>lazyPostCSS(ctx.rootDirectory, ctx.supportedBrowsers, ctx.experimental.disablePostcssPresetEnv);
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: {
// 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 = [];
// Resolve the configured font loaders, the resolved files are noop files that next-font-loader will match
let fontLoaders = ctx.experimental.fontLoaders ? ctx.experimental.fontLoaders.map(({ loader: fontLoader , options })=>[
path.join(require.resolve(fontLoader), "../target.css"),
options,
]) : undefined;
fontLoaders == null ? void 0 : fontLoaders.forEach(([fontLoaderPath, fontLoaderOptions])=>{
// Matches the resolved font loaders noop files to run next-font-loader
fns.push(loader({
oneOf: [
markRemovable({
sideEffects: false,
test: fontLoaderPath,
use: getNextFontLoader(ctx, lazyPostCSSInitializer, fontLoaderOptions)
}),
]
}));
});
// CSS cannot be imported in _document. This comes before everything because
// global CSS nor CSS modules work in said file.
fns.push(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: 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`.
loader({
oneOf: [
// For app dir, it has to match one of the 2 layers and then apply a
// specific loader.
ctx.hasAppDir && !ctx.isProduction ? markRemovable({
sideEffects: false,
test: regexCssModules,
issuerLayer: {
or: [
WEBPACK_LAYERS.server,
WEBPACK_LAYERS.client
]
},
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...getCssModuleLoader(ctx, lazyPostCSSInitializer),
]
}) : null,
ctx.hasAppDir && !ctx.isServer ? markRemovable({
sideEffects: false,
test: regexCssModules,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...getCssModuleLoader(ctx, lazyPostCSSInitializer),
]
}) : null,
markRemovable({
sideEffects: false,
test: regexCssModules,
use: getCssModuleLoader(ctx, lazyPostCSSInitializer)
}),
].filter(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`.
loader({
oneOf: [
// For app dir, we match both server and client layers.
ctx.hasAppDir && !ctx.isProduction ? markRemovable({
sideEffects: false,
test: regexSassModules,
issuerLayer: {
or: [
WEBPACK_LAYERS.server,
WEBPACK_LAYERS.client
]
},
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...getCssModuleLoader(ctx, lazyPostCSSInitializer, sassPreprocessors),
]
}) : null,
ctx.hasAppDir && !ctx.isServer ? markRemovable({
sideEffects: false,
test: regexSassModules,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...getCssModuleLoader(ctx, lazyPostCSSInitializer, sassPreprocessors),
]
}) : null,
markRemovable({
sideEffects: false,
test: regexSassModules,
use: getCssModuleLoader(ctx, lazyPostCSSInitializer, sassPreprocessors)
}),
].filter(nonNullable)
}), // Throw an error for CSS Modules used outside their supported scope
loader({
oneOf: [
markRemovable({
test: [
regexCssModules,
regexSassModules
],
use: {
loader: "error-loader",
options: {
reason: getLocalModuleImportError()
}
}
}),
]
}));
// Global CSS and SASS support.
if (ctx.isServer) {
fns.push(loader({
oneOf: [
ctx.hasAppDir && !ctx.isProduction ? markRemovable({
sideEffects: true,
test: [
regexCssGlobal,
regexSassGlobal
],
issuerLayer: {
or: [
WEBPACK_LAYERS.server,
WEBPACK_LAYERS.client
]
},
use: require.resolve("../../../loaders/next-flight-css-dev-loader")
}) : 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)
}));
} else {
// They are allowed to be loaded when any of the following is true:
// - hasAppDir: If the issuerLayer is RSC
// - 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 allowedExternalCSSImports = {
and: [
{
or: [
/node_modules/,
{
not: [
ctx.rootDirectory
]
},
]
},
]
};
fns.push(loader({
oneOf: [
ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexCssGlobal,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...getGlobalCssLoader(ctx, lazyPostCSSInitializer),
]
}) : null,
ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexSassGlobal,
use: [
require.resolve("../../../loaders/next-flight-css-dev-loader"),
...getGlobalCssLoader(ctx, lazyPostCSSInitializer, sassPreprocessors),
]
}) : null,
!ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexCssGlobal,
include: allowedExternalCSSImports,
issuer: shouldIncludeExternalCSSImports ? undefined : {
and: [
ctx.rootDirectory
],
not: [
/node_modules/
]
},
use: getGlobalCssLoader(ctx, lazyPostCSSInitializer)
}) : null,
!ctx.hasAppDir ? markRemovable({
sideEffects: true,
test: regexSassGlobal,
include: allowedExternalCSSImports,
issuer: shouldIncludeExternalCSSImports ? undefined : {
and: [
ctx.rootDirectory
],
not: [
/node_modules/
]
},
use: getGlobalCssLoader(ctx, lazyPostCSSInitializer, sassPreprocessors)
}) : null,
].filter(nonNullable)
}));
if (ctx.customAppFile) {
fns.push(loader({
oneOf: [
markRemovable({
sideEffects: true,
test: regexCssGlobal,
issuer: {
and: [
ctx.customAppFile
]
},
use: getGlobalCssLoader(ctx, lazyPostCSSInitializer)
}),
]
}), loader({
oneOf: [
markRemovable({
sideEffects: true,
test: regexSassGlobal,
issuer: {
and: [
ctx.customAppFile
]
},
use: getGlobalCssLoader(ctx, lazyPostCSSInitializer, sassPreprocessors)
}),
]
}));
}
}
// Throw an error for Global CSS used inside of `node_modules`
if (!shouldIncludeExternalCSSImports) {
fns.push(loader({
oneOf: [
markRemovable({
test: [
regexCssGlobal,
regexSassGlobal
],
issuer: {
and: [
/node_modules/
]
},
use: {
loader: "error-loader",
options: {
reason: getGlobalModuleImportError()
}
}
}),
]
}));
}
// Throw an error for Global CSS used outside of our custom <App> file
fns.push(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: getGlobalImportError()
}
}
}),
]
}));
if (ctx.isClient) {
// Automatically transform references to files (i.e. url()) into URLs
// e.g. url(./logo.svg)
fns.push(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 = require("../../../plugins/mini-css-extract-plugin").default;
fns.push(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
})));
}
const fn = pipe(...fns);
return fn(config);
});
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,36 @@
export function getClientStyleLoader({ hasAppDir , isDevelopment , assetPrefix }) {
// Keep next-style-loader for development mode in `pages/`
if (isDevelopment && !hasAppDir) {
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 = require("../../../../plugins/mini-css-extract-plugin").default;
return {
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: `${assetPrefix}/_next/`,
esModule: false
}
};
}
//# sourceMappingURL=client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/client.ts"],"names":["getClientStyleLoader","hasAppDir","isDevelopment","assetPrefix","loader","options","insert","element","anchorElement","document","querySelector","parentNode","insertBefore","MiniCssExtractPlugin","require","default","publicPath","esModule"],"mappings":"AAEA,OAAO,SAASA,oBAAoB,CAAC,EACnCC,SAAS,CAAA,EACTC,aAAa,CAAA,EACbC,WAAW,CAAA,EAKZ,EAA0B;IACzB,0DAA0D;IAC1D,IAAID,aAAa,IAAI,CAACD,SAAS,EAAE;QAC/B,OAAO;YACLG,MAAM,EAAE,mBAAmB;YAC3BC,OAAO,EAAE;gBACPC,MAAM,EAAE,SAAUC,OAAa,EAAE;oBAC/B,uDAAuD;oBACvD,uDAAuD;oBACvD,uDAAuD;oBACvD,sDAAsD;oBACtD,sDAAsD;oBAEtD,sDAAsD;oBACtD,yBAAyB;oBACzB,IAAIC,aAAa,GAAGC,QAAQ,CAACC,aAAa,CACxC,2BAA2B,CAC5B,AAAC;oBACF,IAAIC,UAAU,GAAGH,aAAa,CAACG,UAAU,AAAC,AAAC,kBAAkB;oBAAnB;oBAE1C,mDAAmD;oBACnD,uDAAuD;oBACvD,2CAA2C;oBAC3CA,UAAU,CAACC,YAAY,CAACL,OAAO,EAAEC,aAAa,CAAC;iBAChD;aACF;SACF,CAAA;KACF;IAED,MAAMK,oBAAoB,GACxBC,OAAO,CAAC,6CAA6C,CAAC,CAACC,OAAO;IAChE,OAAO;QACLX,MAAM,EAAES,oBAAoB,CAACT,MAAM;QACnCC,OAAO,EAAE;YACPW,UAAU,EAAE,CAAC,EAAEb,WAAW,CAAC,OAAO,CAAC;YACnCc,QAAQ,EAAE,KAAK;SAChB;KACF,CAAA;CACF"}

View File

@@ -0,0 +1,11 @@
export 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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/file-resolve.ts"],"names":["cssFileResolve","url","_resourcePath","urlImports","startsWith","test"],"mappings":"AAAA,OAAO,SAASA,cAAc,CAC5BC,GAAW,EACXC,aAAqB,EACrBC,UAAe,EACf;IACA,IAAIF,GAAG,CAACG,UAAU,CAAC,GAAG,CAAC,EAAE;QACvB,OAAO,KAAK,CAAA;KACb;IACD,IAAI,CAACD,UAAU,IAAI,uBAAuBE,IAAI,CAACJ,GAAG,CAAC,EAAE;QACnD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;CACZ"}

View File

@@ -0,0 +1,22 @@
import loaderUtils from "next/dist/compiled/loader-utils3";
import path from "path";
const regexLikeIndexModule = /(?<!pages[\\/])index\.module\.(scss|sass|css)$/;
export function getCssModuleLocalIdent(context, _, exportName, options) {
const relativePath = path.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 = loaderUtils.getHashDigest(Buffer.from(`filePath:${relativePath}#className:${exportName}`), "md5", "base64", 5);
// Have webpack interpolate the `[folder]` or `[name]` to its real value.
return loaderUtils.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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts"],"names":["loaderUtils","path","regexLikeIndexModule","getCssModuleLocalIdent","context","_","exportName","options","relativePath","relative","rootContext","resourcePath","replace","fileNameOrFolder","test","hash","getHashDigest","Buffer","from","interpolateName"],"mappings":"AAAA,OAAOA,WAAW,MAAM,kCAAkC,CAAA;AAC1D,OAAOC,IAAI,MAAM,MAAM,CAAA;AAGvB,MAAMC,oBAAoB,mDAAmD;AAE7E,OAAO,SAASC,sBAAsB,CACpCC,OAAkC,EAClCC,CAAM,EACNC,UAAkB,EAClBC,OAAe,EACf;IACA,MAAMC,YAAY,GAAGP,IAAI,CACtBQ,QAAQ,CAACL,OAAO,CAACM,WAAW,EAAEN,OAAO,CAACO,YAAY,CAAC,CACnDC,OAAO,SAAS,GAAG,CAAC;IAEvB,0EAA0E;IAC1E,2BAA2B;IAC3B,MAAMC,gBAAgB,GAAGX,oBAAoB,CAACY,IAAI,CAACN,YAAY,CAAC,GAC5D,UAAU,GACV,QAAQ;IAEZ,iDAAiD;IACjD,MAAMO,IAAI,GAAGf,WAAW,CAACgB,aAAa,CACpCC,MAAM,CAACC,IAAI,CAAC,CAAC,SAAS,EAAEV,YAAY,CAAC,WAAW,EAAEF,UAAU,CAAC,CAAC,CAAC,EAC/D,KAAK,EACL,QAAQ,EACR,CAAC,CACF;IAED,yEAAyE;IACzE,OACEN,WAAW,CACRmB,eAAe,CACdf,OAAO,EACPS,gBAAgB,GAAG,GAAG,GAAGP,UAAU,GAAG,IAAI,GAAGS,IAAI,EACjDR,OAAO,CACR,CACAK,OAAO,CACN,oEAAoE;IACpE,oEAAoE;IACpE,QAAQ;iBAER,GAAG,CACJ,AACD,+DAA+D;IAC/D,iEAAiE;KAChEA,OAAO,oBAAoB,GAAG,CAAC,AAChC,uFAAuF;IACvF,sDAAsD;KACrDA,OAAO,iBAAiB,MAAM,CAAC,CACnC;CACF"}

View File

@@ -0,0 +1,39 @@
import { getClientStyleLoader } from "./client";
import { cssFileResolve } from "./file-resolve";
export function getGlobalCssLoader(ctx, postcss, preProcessors = []) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development more or production mode style
// loader
loaders.push(getClientStyleLoader({
hasAppDir: ctx.hasAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix
}));
}
// 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)=>cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>cssFileResolve(url, resourcePath, ctx.experimental.urlImports)
}
});
// 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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/global.ts"],"names":["getClientStyleLoader","cssFileResolve","getGlobalCssLoader","ctx","postcss","preProcessors","loaders","isClient","push","hasAppDir","isDevelopment","assetPrefix","loader","require","resolve","options","importLoaders","length","modules","url","resourcePath","experimental","urlImports","import","_","slice","reverse"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ,UAAU,CAAA;AAC/C,SAASC,cAAc,QAAQ,gBAAgB,CAAA;AAE/C,OAAO,SAASC,kBAAkB,CAChCC,GAAyB,EACzBC,OAAY,EACZC,aAAgD,GAAG,EAAE,EAC3B;IAC1B,MAAMC,OAAO,GAA6B,EAAE;IAE5C,IAAIH,GAAG,CAACI,QAAQ,EAAE;QAChB,4DAA4D;QAC5D,SAAS;QACTD,OAAO,CAACE,IAAI,CACVR,oBAAoB,CAAC;YACnBS,SAAS,EAAEN,GAAG,CAACM,SAAS;YACxBC,aAAa,EAAEP,GAAG,CAACO,aAAa;YAChCC,WAAW,EAAER,GAAG,CAACQ,WAAW;SAC7B,CAAC,CACH;KACF;IAED,sCAAsC;IACtCL,OAAO,CAACE,IAAI,CAAC;QACXI,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,oCAAoC,CAAC;QAC7DC,OAAO,EAAE;YACPX,OAAO;YACPY,aAAa,EAAE,CAAC,GAAGX,aAAa,CAACY,MAAM;YACvC,4CAA4C;YAC5CC,OAAO,EAAE,KAAK;YACdC,GAAG,EAAE,CAACA,GAAW,EAAEC,YAAoB,GACrCnB,cAAc,CAACkB,GAAG,EAAEC,YAAY,EAAEjB,GAAG,CAACkB,YAAY,CAACC,UAAU,CAAC;YAChEC,MAAM,EAAE,CAACJ,GAAW,EAAEK,CAAM,EAAEJ,YAAoB,GAChDnB,cAAc,CAACkB,GAAG,EAAEC,YAAY,EAAEjB,GAAG,CAACkB,YAAY,CAACC,UAAU,CAAC;SACjE;KACF,CAAC;IAEF,cAAc;IACdhB,OAAO,CAACE,IAAI,CAAC;QACXI,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,wCAAwC,CAAC;QACjEC,OAAO,EAAE;YACPX,OAAO;SACR;KACF,CAAC;IAEFE,OAAO,CAACE,IAAI,CACV,sEAAsE;IACtE,0BAA0B;OACvBH,aAAa,CAACoB,KAAK,EAAE,CAACC,OAAO,EAAE,CACnC;IAED,OAAOpB,OAAO,CAAA;CACf"}

View File

@@ -0,0 +1,4 @@
export * from "./global";
export * from "./modules";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA"}

View File

@@ -0,0 +1,55 @@
import { getClientStyleLoader } from "./client";
import { cssFileResolve } from "./file-resolve";
import { getCssModuleLocalIdent } from "./getCssModuleLocalIdent";
export function getCssModuleLoader(ctx, postcss, preProcessors = []) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development more or production mode style
// loader
loaders.push(getClientStyleLoader({
hasAppDir: ctx.hasAppDir,
isDevelopment: ctx.isDevelopment,
assetPrefix: ctx.assetPrefix
}));
}
// 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)=>cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>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
}
}
});
// 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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/modules.ts"],"names":["getClientStyleLoader","cssFileResolve","getCssModuleLocalIdent","getCssModuleLoader","ctx","postcss","preProcessors","loaders","isClient","push","hasAppDir","isDevelopment","assetPrefix","loader","require","resolve","options","importLoaders","length","esModule","url","resourcePath","experimental","urlImports","import","_","modules","exportLocalsConvention","exportOnlyLocals","isServer","mode","getLocalIdent","slice","reverse"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAU,CAAA;AAC/C,SAASC,cAAc,QAAQ,gBAAgB,CAAA;AAC/C,SAASC,sBAAsB,QAAQ,0BAA0B,CAAA;AAEjE,OAAO,SAASC,kBAAkB,CAChCC,GAAyB,EACzBC,OAAY,EACZC,aAAgD,GAAG,EAAE,EAC3B;IAC1B,MAAMC,OAAO,GAA6B,EAAE;IAE5C,IAAIH,GAAG,CAACI,QAAQ,EAAE;QAChB,4DAA4D;QAC5D,SAAS;QACTD,OAAO,CAACE,IAAI,CACVT,oBAAoB,CAAC;YACnBU,SAAS,EAAEN,GAAG,CAACM,SAAS;YACxBC,aAAa,EAAEP,GAAG,CAACO,aAAa;YAChCC,WAAW,EAAER,GAAG,CAACQ,WAAW;SAC7B,CAAC,CACH;KACF;IAED,sCAAsC;IACtCL,OAAO,CAACE,IAAI,CAAC;QACXI,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,oCAAoC,CAAC;QAC7DC,OAAO,EAAE;YACPX,OAAO;YACPY,aAAa,EAAE,CAAC,GAAGX,aAAa,CAACY,MAAM;YACvC,4CAA4C;YAC5CC,QAAQ,EAAE,KAAK;YACfC,GAAG,EAAE,CAACA,GAAW,EAAEC,YAAoB,GACrCpB,cAAc,CAACmB,GAAG,EAAEC,YAAY,EAAEjB,GAAG,CAACkB,YAAY,CAACC,UAAU,CAAC;YAChEC,MAAM,EAAE,CAACJ,GAAW,EAAEK,CAAM,EAAEJ,YAAoB,GAChDpB,cAAc,CAACmB,GAAG,EAAEC,YAAY,EAAEjB,GAAG,CAACkB,YAAY,CAACC,UAAU,CAAC;YAChEG,OAAO,EAAE;gBACP,mEAAmE;gBACnEC,sBAAsB,EAAE,MAAM;gBAC9B,2CAA2C;gBAC3CC,gBAAgB,EAAExB,GAAG,CAACyB,QAAQ;gBAC9B,6DAA6D;gBAC7D,iCAAiC;gBACjCC,IAAI,EAAE,MAAM;gBACZ,oDAAoD;gBACpD,uDAAuD;gBACvD,eAAe;gBACf,2DAA2D;gBAC3D,aAAa;gBACbC,aAAa,EAAE7B,sBAAsB;aACtC;SACF;KACF,CAAC;IAEF,cAAc;IACdK,OAAO,CAACE,IAAI,CAAC;QACXI,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,wCAAwC,CAAC;QACjEC,OAAO,EAAE;YACPX,OAAO;SACR;KACF,CAAC;IAEFE,OAAO,CAACE,IAAI,CACV,sEAAsE;IACtE,0BAA0B;OACvBH,aAAa,CAAC0B,KAAK,EAAE,CAACC,OAAO,EAAE,CACnC;IAED,OAAO1B,OAAO,CAAA;CACf"}

View File

@@ -0,0 +1,52 @@
import { getClientStyleLoader } from "./client";
import { cssFileResolve } from "./file-resolve";
export function getNextFontLoader(ctx, postcss, fontLoaderOptions) {
const loaders = [];
if (ctx.isClient) {
// Add appropriate development mode or production mode style
// loader
loaders.push(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)=>cssFileResolve(url, resourcePath, ctx.experimental.urlImports),
import: (url, _, resourcePath)=>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,
fontLoaderOptions,
postcss
}
});
return loaders;
}
//# sourceMappingURL=next-font.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../build/webpack/config/blocks/css/loaders/next-font.ts"],"names":["getClientStyleLoader","cssFileResolve","getNextFontLoader","ctx","postcss","fontLoaderOptions","loaders","isClient","push","hasAppDir","isDevelopment","assetPrefix","loader","require","resolve","options","importLoaders","esModule","url","resourcePath","experimental","urlImports","import","_","modules","exportLocalsConvention","exportOnlyLocals","isServer","mode","getLocalIdent","_context","_localIdentName","exportName","_options","meta","fontFamilyHash","fontLoader","isDev"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAU,CAAA;AAC/C,SAASC,cAAc,QAAQ,gBAAgB,CAAA;AAE/C,OAAO,SAASC,iBAAiB,CAC/BC,GAAyB,EACzBC,OAAY,EACZC,iBAAsB,EACI;IAC1B,MAAMC,OAAO,GAA6B,EAAE;IAE5C,IAAIH,GAAG,CAACI,QAAQ,EAAE;QAChB,4DAA4D;QAC5D,SAAS;QACTD,OAAO,CAACE,IAAI,CACVR,oBAAoB,CAAC;YACnBS,SAAS,EAAEN,GAAG,CAACM,SAAS;YACxBC,aAAa,EAAEP,GAAG,CAACO,aAAa;YAChCC,WAAW,EAAER,GAAG,CAACQ,WAAW;SAC7B,CAAC,CACH;KACF;IAEDL,OAAO,CAACE,IAAI,CAAC;QACXI,MAAM,EAAEC,OAAO,CAACC,OAAO,CAAC,oCAAoC,CAAC;QAC7DC,OAAO,EAAE;YACPX,OAAO;YACPY,aAAa,EAAE,CAAC;YAChB,4CAA4C;YAC5CC,QAAQ,EAAE,KAAK;YACfC,GAAG,EAAE,CAACA,GAAW,EAAEC,YAAoB,GACrClB,cAAc,CAACiB,GAAG,EAAEC,YAAY,EAAEhB,GAAG,CAACiB,YAAY,CAACC,UAAU,CAAC;YAChEC,MAAM,EAAE,CAACJ,GAAW,EAAEK,CAAM,EAAEJ,YAAoB,GAChDlB,cAAc,CAACiB,GAAG,EAAEC,YAAY,EAAEhB,GAAG,CAACiB,YAAY,CAACC,UAAU,CAAC;YAChEG,OAAO,EAAE;gBACP,mEAAmE;gBACnEC,sBAAsB,EAAE,MAAM;gBAC9B,2CAA2C;gBAC3CC,gBAAgB,EAAEvB,GAAG,CAACwB,QAAQ;gBAC9B,6DAA6D;gBAC7D,iCAAiC;gBACjCC,IAAI,EAAE,MAAM;gBACZC,aAAa,EAAE,CACbC,QAAa,EACbC,eAAoB,EACpBC,UAAkB,EAClBC,QAAa,EACbC,IAAS,GACN;oBACH,6BAA6B;oBAC7B,OAAO,CAAC,EAAE,EAAEF,UAAU,CAAC,CAAC,EAAEE,IAAI,CAACC,cAAc,CAAC,CAAC,CAAA;iBAChD;aACF;YACDC,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IAEF9B,OAAO,CAACE,IAAI,CAAC;QACXI,MAAM,EAAE,kBAAkB;QAC1BG,OAAO,EAAE;YACPsB,KAAK,EAAElC,GAAG,CAACO,aAAa;YACxBiB,QAAQ,EAAExB,GAAG,CAACwB,QAAQ;YACtBhB,WAAW,EAAER,GAAG,CAACQ,WAAW;YAC5BN,iBAAiB;YACjBD,OAAO;SACR;KACF,CAAC;IAEF,OAAOE,OAAO,CAAA;CACf"}

View File

@@ -0,0 +1,15 @@
import chalk from "next/dist/compiled/chalk";
export function getGlobalImportError() {
return `Global CSS ${chalk.bold("cannot")} be imported from files other than your ${chalk.bold("Custom <App>")}. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to ${chalk.cyan("pages/_app.js")}. Or convert the import to Component-Level CSS (CSS Modules).\nRead more: https://nextjs.org/docs/messages/css-global`;
}
export function getGlobalModuleImportError() {
return `Global CSS ${chalk.bold("cannot")} be imported from within ${chalk.bold("node_modules")}.\nRead more: https://nextjs.org/docs/messages/css-npm`;
}
export function getLocalModuleImportError() {
return `CSS Modules ${chalk.bold("cannot")} be imported from within ${chalk.bold("node_modules")}.\nRead more: https://nextjs.org/docs/messages/css-modules-npm`;
}
export function getCustomDocumentError() {
return `CSS ${chalk.bold("cannot")} be imported within ${chalk.cyan("pages/_document.js")}. Please move global styles to ${chalk.cyan("pages/_app.js")}.`;
}
//# sourceMappingURL=messages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/config/blocks/css/messages.ts"],"names":["chalk","getGlobalImportError","bold","cyan","getGlobalModuleImportError","getLocalModuleImportError","getCustomDocumentError"],"mappings":"AAAA,OAAOA,KAAK,MAAM,0BAA0B,CAAA;AAE5C,OAAO,SAASC,oBAAoB,GAAG;IACrC,OAAO,CAAC,WAAW,EAAED,KAAK,CAACE,IAAI,CAC7B,QAAQ,CACT,CAAC,wCAAwC,EAAEF,KAAK,CAACE,IAAI,CACpD,cAAc,CACf,CAAC,qHAAqH,EAAEF,KAAK,CAACG,IAAI,CACjI,eAAe,CAChB,CAAC,qHAAqH,CAAC,CAAA;CACzH;AAED,OAAO,SAASC,0BAA0B,GAAG;IAC3C,OAAO,CAAC,WAAW,EAAEJ,KAAK,CAACE,IAAI,CAC7B,QAAQ,CACT,CAAC,yBAAyB,EAAEF,KAAK,CAACE,IAAI,CACrC,cAAc,CACf,CAAC,sDAAsD,CAAC,CAAA;CAC1D;AAED,OAAO,SAASG,yBAAyB,GAAG;IAC1C,OAAO,CAAC,YAAY,EAAEL,KAAK,CAACE,IAAI,CAC9B,QAAQ,CACT,CAAC,yBAAyB,EAAEF,KAAK,CAACE,IAAI,CACrC,cAAc,CACf,CAAC,8DAA8D,CAAC,CAAA;CAClE;AAED,OAAO,SAASI,sBAAsB,GAAG;IACvC,OAAO,CAAC,IAAI,EAAEN,KAAK,CAACE,IAAI,CAAC,QAAQ,CAAC,CAAC,oBAAoB,EAAEF,KAAK,CAACG,IAAI,CACjE,oBAAoB,CACrB,CAAC,+BAA+B,EAAEH,KAAK,CAACG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;CAClE"}

View File

@@ -0,0 +1,152 @@
import chalk from "next/dist/compiled/chalk";
import { findConfig } from "../../../../../lib/find-config";
const genericErrorText = "Malformed PostCSS Configuration";
function getError_NullConfig(pluginName) {
return `${chalk.red.bold("Error")}: Your PostCSS configuration for '${pluginName}' cannot have ${chalk.bold("null")} configuration.\nTo disable '${pluginName}', pass ${chalk.bold("false")}, otherwise, pass ${chalk.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(`${chalk.yellow.bold("Warning")}: Please remove the ${chalk.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 new Error(genericErrorText);
}
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);
}
export async function getPostCssPlugins(dir, supportedBrowsers, disablePostcssPresetEnv = false) {
let config = await findConfig(dir, "postcss");
if (config == null) {
config = {
plugins: getDefaultPlugins(supportedBrowsers, disablePostcssPresetEnv)
};
}
if (typeof config === "function") {
throw 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");
}
// Warn user about configuration keys which are not respected
const invalidKey = Object.keys(config).find((key)=>key !== "plugins");
if (invalidKey) {
console.warn(`${chalk.yellow.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 new Error(`Your custom PostCSS configuration must export a \`plugins\` key.`);
}
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 new Error(genericErrorText);
}
acc.push([
curr,
p
]);
return acc;
}, []);
}
const parsed = [];
plugins.forEach((plugin)=>{
if (plugin == null) {
console.warn(`${chalk.yellow.bold("Warning")}: A ${chalk.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(`${chalk.red.bold("Error")}: A PostCSS Plugin must be provided as a ${chalk.bold("string")}. Instead, we got: '${pluginName}'.\n` + "Read more: https://nextjs.org/docs/messages/postcss-shape");
} else {
console.error(`${chalk.red.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 new Error(genericErrorText);
}
} else if (typeof plugin === "function") {
console.error(`${chalk.red.bold("Error")}: A PostCSS Plugin was passed as a function using require(), but it must be provided as a ${chalk.bold("string")}.\nRead more: https://nextjs.org/docs/messages/postcss-shape`);
throw new Error(genericErrorText);
} else {
console.error(`${chalk.red.bold("Error")}: An unknown PostCSS plugin was provided (${plugin}).\n` + "Read more: https://nextjs.org/docs/messages/postcss-shape");
throw new Error(genericErrorText);
}
});
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

View File

@@ -0,0 +1,27 @@
import curry from "next/dist/compiled/lodash.curry";
import { nextImageLoaderRegex } from "../../../../webpack-config";
import { loader } from "../../helpers";
import { pipe } from "../../utils";
import { getCustomDocumentImageError } from "./messages";
export const images = curry(async function images(_ctx, config) {
const fns = [
loader({
oneOf: [
{
test: nextImageLoaderRegex,
use: {
loader: "error-loader",
options: {
reason: getCustomDocumentImageError()
}
},
issuer: /pages[\\/]_document\./
},
]
}),
];
const fn = pipe(...fns);
return fn(config);
});
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/config/blocks/images/index.ts"],"names":["curry","nextImageLoaderRegex","loader","pipe","getCustomDocumentImageError","images","_ctx","config","fns","oneOf","test","use","options","reason","issuer","fn"],"mappings":"AAAA,OAAOA,KAAK,MAAM,iCAAiC,CAAA;AAEnD,SAASC,oBAAoB,QAAQ,4BAA4B,CAAA;AACjE,SAASC,MAAM,QAAQ,eAAe,CAAA;AACtC,SAAgDC,IAAI,QAAQ,aAAa,CAAA;AACzE,SAASC,2BAA2B,QAAQ,YAAY,CAAA;AAExD,OAAO,MAAMC,MAAM,GAAGL,KAAK,CAAC,eAAeK,MAAM,CAC/CC,IAA0B,EAC1BC,MAA6B,EAC7B;IACA,MAAMC,GAAG,GAAsB;QAC7BN,MAAM,CAAC;YACLO,KAAK,EAAE;gBACL;oBACEC,IAAI,EAAET,oBAAoB;oBAC1BU,GAAG,EAAE;wBACHT,MAAM,EAAE,cAAc;wBACtBU,OAAO,EAAE;4BACPC,MAAM,EAAET,2BAA2B,EAAE;yBACtC;qBACF;oBACDU,MAAM,yBAAyB;iBAChC;aACF;SACF,CAAC;KACH;IAED,MAAMC,EAAE,GAAGZ,IAAI,IAAIK,GAAG,CAAC;IACvB,OAAOO,EAAE,CAACR,MAAM,CAAC,CAAA;CAClB,CAAC,CAAA"}

View File

@@ -0,0 +1,6 @@
import chalk from "next/dist/compiled/chalk";
export function getCustomDocumentImageError() {
return `Images ${chalk.bold("cannot")} be imported within ${chalk.cyan("pages/_document.js")}. Please move image imports that need to be displayed on every page into ${chalk.cyan("pages/_app.js")}.\nRead more: https://nextjs.org/docs/messages/custom-document-image-import`;
}
//# sourceMappingURL=messages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../build/webpack/config/blocks/images/messages.ts"],"names":["chalk","getCustomDocumentImageError","bold","cyan"],"mappings":"AAAA,OAAOA,KAAK,MAAM,0BAA0B,CAAA;AAE5C,OAAO,SAASC,2BAA2B,GAAG;IAC5C,OAAO,CAAC,OAAO,EAAED,KAAK,CAACE,IAAI,CAAC,QAAQ,CAAC,CAAC,oBAAoB,EAAEF,KAAK,CAACG,IAAI,CACpE,oBAAoB,CACrB,CAAC,yEAAyE,EAAEH,KAAK,CAACG,IAAI,CACrF,eAAe,CAChB,CAAC,2EAA2E,CAAC,CAAA;CAC/E"}

View File

@@ -0,0 +1,47 @@
import curry from "next/dist/compiled/lodash.curry";
export const loader = curry(function loader(rule, config) {
var ref;
if (!config.module) {
config.module = {
rules: []
};
}
if (rule.oneOf) {
var ref1;
const existing = (ref1 = config.module.rules) == null ? void 0 : ref1.find((arrayRule)=>arrayRule && typeof arrayRule === "object" && arrayRule.oneOf);
if (existing && typeof existing === "object") {
existing.oneOf.push(...rule.oneOf);
return config;
}
}
(ref = config.module.rules) == null ? void 0 : ref.push(rule);
return config;
});
export const unshiftLoader = curry(function unshiftLoader(rule, config) {
var ref;
if (!config.module) {
config.module = {
rules: []
};
}
if (rule.oneOf) {
var ref2;
const existing = (ref2 = config.module.rules) == null ? void 0 : ref2.find((arrayRule)=>arrayRule && typeof arrayRule === "object" && arrayRule.oneOf);
if (existing && typeof existing === "object") {
var ref3;
(ref3 = existing.oneOf) == null ? void 0 : ref3.unshift(...rule.oneOf);
return config;
}
}
(ref = config.module.rules) == null ? void 0 : ref.unshift(rule);
return config;
});
export const plugin = curry(function plugin(p, config) {
if (!config.plugins) {
config.plugins = [];
}
config.plugins.push(p);
return config;
});
//# sourceMappingURL=helpers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/config/helpers.ts"],"names":["curry","loader","rule","config","module","rules","oneOf","existing","find","arrayRule","push","unshiftLoader","unshift","plugin","p","plugins"],"mappings":"AAAA,OAAOA,KAAK,MAAM,iCAAiC,CAAA;AAGnD,OAAO,MAAMC,MAAM,GAAGD,KAAK,CAAC,SAASC,MAAM,CACzCC,IAAyB,EACzBC,MAA6B,EAC7B;QAgBAA,GAAmB;IAfnB,IAAI,CAACA,MAAM,CAACC,MAAM,EAAE;QAClBD,MAAM,CAACC,MAAM,GAAG;YAAEC,KAAK,EAAE,EAAE;SAAE;KAC9B;IAED,IAAIH,IAAI,CAACI,KAAK,EAAE;YACGH,IAAmB;QAApC,MAAMI,QAAQ,GAAGJ,CAAAA,IAAmB,GAAnBA,MAAM,CAACC,MAAM,CAACC,KAAK,SAAM,GAAzBF,KAAAA,CAAyB,GAAzBA,IAAmB,CAAEK,IAAI,CACxC,CAACC,SAAS,GACRA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACH,KAAK,CAChE;QACD,IAAIC,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;YAC5CA,QAAQ,CAACD,KAAK,CAAEI,IAAI,IAAIR,IAAI,CAACI,KAAK,CAAC;YACnC,OAAOH,MAAM,CAAA;SACd;KACF;IAEDA,CAAAA,GAAmB,GAAnBA,MAAM,CAACC,MAAM,CAACC,KAAK,SAAM,GAAzBF,KAAAA,CAAyB,GAAzBA,GAAmB,CAAEO,IAAI,CAACR,IAAI,CAAC,CAAA;IAC/B,OAAOC,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,OAAO,MAAMQ,aAAa,GAAGX,KAAK,CAAC,SAASW,aAAa,CACvDT,IAAyB,EACzBC,MAA6B,EAC7B;QAgBAA,GAAmB;IAfnB,IAAI,CAACA,MAAM,CAACC,MAAM,EAAE;QAClBD,MAAM,CAACC,MAAM,GAAG;YAAEC,KAAK,EAAE,EAAE;SAAE;KAC9B;IAED,IAAIH,IAAI,CAACI,KAAK,EAAE;YACGH,IAAmB;QAApC,MAAMI,QAAQ,GAAGJ,CAAAA,IAAmB,GAAnBA,MAAM,CAACC,MAAM,CAACC,KAAK,SAAM,GAAzBF,KAAAA,CAAyB,GAAzBA,IAAmB,CAAEK,IAAI,CACxC,CAACC,SAAS,GACRA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAIA,SAAS,CAACH,KAAK,CAChE;QACD,IAAIC,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;gBAC5CA,IAAc;YAAdA,CAAAA,IAAc,GAAdA,QAAQ,CAACD,KAAK,SAAS,GAAvBC,KAAAA,CAAuB,GAAvBA,IAAc,CAAEK,OAAO,IAAIV,IAAI,CAACI,KAAK,CAAC,CAAA;YACtC,OAAOH,MAAM,CAAA;SACd;KACF;IAEDA,CAAAA,GAAmB,GAAnBA,MAAM,CAACC,MAAM,CAACC,KAAK,SAAS,GAA5BF,KAAAA,CAA4B,GAA5BA,GAAmB,CAAES,OAAO,CAACV,IAAI,CAAC,CAAA;IAClC,OAAOC,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,OAAO,MAAMU,MAAM,GAAGb,KAAK,CAAC,SAASa,MAAM,CACzCC,CAAgC,EAChCX,MAA6B,EAC7B;IACA,IAAI,CAACA,MAAM,CAACY,OAAO,EAAE;QACnBZ,MAAM,CAACY,OAAO,GAAG,EAAE;KACpB;IACDZ,MAAM,CAACY,OAAO,CAACL,IAAI,CAACI,CAAC,CAAC;IACtB,OAAOX,MAAM,CAAA;CACd,CAAC,CAAA"}

View File

@@ -0,0 +1,35 @@
import { base } from "./blocks/base";
import { css } from "./blocks/css";
import { images } from "./blocks/images";
import { pipe } from "./utils";
export async function buildConfiguration(config, { hasAppDir , supportedBrowsers , rootDirectory , customAppFile , isDevelopment , isServer , isEdgeRuntime , targetWeb , assetPrefix , sassOptions , productionBrowserSourceMaps , future , transpilePackages , experimental , disableStaticImages }) {
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
};
let fns = [
base(ctx),
css(ctx)
];
if (!disableStaticImages) {
fns.push(images(ctx));
}
const fn = pipe(...fns);
return fn(config);
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/config/index.ts"],"names":["base","css","images","pipe","buildConfiguration","config","hasAppDir","supportedBrowsers","rootDirectory","customAppFile","isDevelopment","isServer","isEdgeRuntime","targetWeb","assetPrefix","sassOptions","productionBrowserSourceMaps","future","transpilePackages","experimental","disableStaticImages","ctx","isProduction","isClient","endsWith","slice","fns","push","fn"],"mappings":"AAIA,SAASA,IAAI,QAAQ,eAAe,CAAA;AACpC,SAASC,GAAG,QAAQ,cAAc,CAAA;AAClC,SAASC,MAAM,QAAQ,iBAAiB,CAAA;AACxC,SAASC,IAAI,QAAQ,SAAS,CAAA;AAE9B,OAAO,eAAeC,kBAAkB,CACtCC,MAA6B,EAC7B,EACEC,SAAS,CAAA,EACTC,iBAAiB,CAAA,EACjBC,aAAa,CAAA,EACbC,aAAa,CAAA,EACbC,aAAa,CAAA,EACbC,QAAQ,CAAA,EACRC,aAAa,CAAA,EACbC,SAAS,CAAA,EACTC,WAAW,CAAA,EACXC,WAAW,CAAA,EACXC,2BAA2B,CAAA,EAC3BC,MAAM,CAAA,EACNC,iBAAiB,CAAA,EACjBC,YAAY,CAAA,EACZC,mBAAmB,CAAA,EAiBpB,EAC+B;IAChC,MAAMC,GAAG,GAAyB;QAChCf,SAAS;QACTC,iBAAiB;QACjBC,aAAa;QACbC,aAAa;QACbC,aAAa;QACbY,YAAY,EAAE,CAACZ,aAAa;QAC5BC,QAAQ;QACRC,aAAa;QACbW,QAAQ,EAAE,CAACZ,QAAQ;QACnBE,SAAS;QACTC,WAAW,EAAEA,WAAW,GACpBA,WAAW,CAACU,QAAQ,CAAC,GAAG,CAAC,GACvBV,WAAW,CAACW,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACxBX,WAAW,GACb,EAAE;QACNC,WAAW;QACXC,2BAA2B;QAC3BE,iBAAiB;QACjBD,MAAM;QACNE,YAAY;KACb;IAED,IAAIO,GAAG,GAAG;QAAC1B,IAAI,CAACqB,GAAG,CAAC;QAAEpB,GAAG,CAACoB,GAAG,CAAC;KAAC;IAC/B,IAAI,CAACD,mBAAmB,EAAE;QACxBM,GAAG,CAACC,IAAI,CAACzB,MAAM,CAACmB,GAAG,CAAC,CAAC;KACtB;IACD,MAAMO,EAAE,GAAGzB,IAAI,IAAIuB,GAAG,CAAC;IACvB,OAAOE,EAAE,CAACvB,MAAM,CAAC,CAAA;CAClB"}

View File

@@ -0,0 +1,3 @@
export const pipe = (...fns)=>(param)=>fns.reduce(async (result, next)=>next(await result), param);
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../build/webpack/config/utils.ts"],"names":["pipe","fns","param","reduce","result","next"],"mappings":"AAgCA,OAAO,MAAMA,IAAI,GACf,CAAI,GAAGC,GAAG,AAAiC,GAC3C,CAACC,KAAQ,GACPD,GAAG,CAACE,MAAM,CACR,OAAOC,MAAsB,EAAEC,IAAI,GAAKA,IAAI,CAAC,MAAMD,MAAM,CAAC,EAC1DF,KAAK,CACN,CAAA"}