rsnext/examples/cms-sitecore-xmcloud/next.config.js
Steven 4466ba436b
chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00

72 lines
2 KiB
JavaScript

const jssConfig = require("./src/temp/config");
const { getPublicUrl } = require("@sitecore-jss/sitecore-jss-nextjs");
const plugins = require("./src/temp/next-config-plugins") || {};
const publicUrl = getPublicUrl();
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
// Set assetPrefix to our public URL
assetPrefix: publicUrl,
// Allow specifying a distinct distDir when concurrently running app in a container
distDir: process.env.NEXTJS_DIST_DIR || ".next",
// Make the same PUBLIC_URL available as an environment variable on the client bundle
env: {
PUBLIC_URL: publicUrl,
},
i18n: {
// These are all the locales you want to support in your application.
// These should generally match (or at least be a subset of) those in Sitecore.
locales: ["en"],
// This is the locale that will be used when visiting a non-locale
// prefixed path e.g. `/styleguide`.
defaultLocale: jssConfig.defaultLanguage,
},
// Enable React Strict Mode
reactStrictMode: true,
async rewrites() {
// When in connected mode we want to proxy Sitecore paths off to Sitecore
return [
// API endpoints
{
source: "/sitecore/api/:path*",
destination: `${jssConfig.sitecoreApiHost}/sitecore/api/:path*`,
},
// media items
{
source: "/-/:path*",
destination: `${jssConfig.sitecoreApiHost}/-/:path*`,
},
// visitor identification
{
source: "/layouts/system/:path*",
destination: `${jssConfig.sitecoreApiHost}/layouts/system/:path*`,
},
// healthz check
{
source: "/healthz",
destination: "/api/healthz",
},
// rewrite for Sitecore service pages
{
source: "/sitecore/service/:path*",
destination: `${jssConfig.sitecoreApiHost}/sitecore/service/:path*`,
},
];
},
};
module.exports = () => {
// Run the base config through any configured plugins
return Object.values(plugins).reduce(
(acc, plugin) => plugin(acc),
nextConfig,
);
};