feat(nextjs): improve type checking for nextjs config file (#11497)
Co-authored-by: Nicholas Cunningham <ndcunningham>
This commit is contained in:
parent
4917239100
commit
522dcdd339
@ -12,7 +12,7 @@ function patchNextCSSWithLess(
|
|||||||
|
|
||||||
patchNextCSSWithLess();
|
patchNextCSSWithLess();
|
||||||
|
|
||||||
function withLess({ lessLoaderOptions = {}, ...nextConfig }) {
|
export function withLess({ lessLoaderOptions = {}, ...nextConfig }) {
|
||||||
return Object.assign({}, nextConfig, {
|
return Object.assign({}, nextConfig, {
|
||||||
webpack(config, opts) {
|
webpack(config, opts) {
|
||||||
// there are 2 relevant sass rules in next.js - css modules and global css
|
// there are 2 relevant sass rules in next.js - css modules and global css
|
||||||
@ -95,4 +95,5 @@ function withLess({ lessLoaderOptions = {}, ...nextConfig }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = withLess;
|
module.exports = withLess;
|
||||||
|
module.exports.withLess = withLess;
|
||||||
module.exports.patchNext = patchNextCSSWithLess;
|
module.exports.patchNext = patchNextCSSWithLess;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ function regexEqual(x, y) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function withNx(nextConfig = {} as WithNxOptions) {
|
export function withNx(nextConfig = {} as WithNxOptions) {
|
||||||
const userWebpack = nextConfig.webpack || ((x) => x);
|
const userWebpack = nextConfig.webpack || ((x) => x);
|
||||||
const { nx, ...validNextConfig } = nextConfig;
|
const { nx, ...validNextConfig } = nextConfig;
|
||||||
return {
|
return {
|
||||||
@ -154,4 +154,7 @@ function addNxEnvVariables(config: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support for older generated code: `const withNx = require('@nrwl/next/plugins/with-nx');`
|
||||||
module.exports = withNx;
|
module.exports = withNx;
|
||||||
|
// Support for newer generated code: `const { withNx } = require(...);`
|
||||||
|
module.exports.withNx = withNx;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ function patchNextCSSWithStylus(
|
|||||||
|
|
||||||
patchNextCSSWithStylus();
|
patchNextCSSWithStylus();
|
||||||
|
|
||||||
function withStylus({ stylusLoaderOptions = {}, ...nextConfig }: any) {
|
export function withStylus({ stylusLoaderOptions = {}, ...nextConfig }: any) {
|
||||||
return Object.assign({}, nextConfig, {
|
return Object.assign({}, nextConfig, {
|
||||||
webpack(config, opts) {
|
webpack(config, opts) {
|
||||||
// there are 2 relevant sass rules in next.js - css modules and global css
|
// there are 2 relevant sass rules in next.js - css modules and global css
|
||||||
@ -94,4 +94,5 @@ function withStylus({ stylusLoaderOptions = {}, ...nextConfig }: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = withStylus;
|
module.exports = withStylus;
|
||||||
|
module.exports.withStylus = withStylus;
|
||||||
module.exports.patchNext = patchNextCSSWithStylus;
|
module.exports.patchNext = patchNextCSSWithStylus;
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
|
//@ts-check
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const withNx = require('@nrwl/next/plugins/with-nx');
|
const { withNx } = require('@nrwl/next/plugins/with-nx');
|
||||||
|
|
||||||
<% if (style === 'less') { %>
|
<% if (style === 'less') { %>
|
||||||
// This plugin is needed until this PR is merged.
|
// This plugin is needed until this PR is merged.
|
||||||
// https://github.com/vercel/next.js/pull/23185
|
// https://github.com/vercel/next.js/pull/23185
|
||||||
const withLess = require('@nrwl/next/plugins/with-less');
|
const { withLess } = require('@nrwl/next/plugins/with-less');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
|
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
|
||||||
@ -19,7 +21,7 @@ const nextConfig = {
|
|||||||
|
|
||||||
module.exports = withLess(withNx(nextConfig));
|
module.exports = withLess(withNx(nextConfig));
|
||||||
<% } else if (style === 'styl') { %>
|
<% } else if (style === 'styl') { %>
|
||||||
const withStylus = require('@nrwl/next/plugins/with-stylus');
|
const { withStylus } = require('@nrwl/next/plugins/with-stylus');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
|
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user