-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Pigment migration docs doesn't mention spacing, breakpoints etc are no longer callable #43563
Comments
@abriginets Could you also share your |
Sure, here it is next.config.mjsimport bundleAnalyzerPlugin from '@next/bundle-analyzer';
import { extendTheme, withPigment } from '@pigment-css/nextjs-plugin';
import { withSentryConfig } from '@sentry/nextjs';
import createNextIntlPlugin from 'next-intl/plugin';
import pwaPlugin from 'next-pwa';
const { BACKEND_URL } = process.env;
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
compress: false,
output: 'standalone',
images: {
domains: ['mpics.avs.io', 'pics.avs.io', 'yasen.aviasales.ru'],
},
experimental: {
nextScriptWorkers: true,
proxyTimeout: 60_000,
},
poweredByHeader: false,
swcMinify: true,
reactStrictMode: true,
async rewrites() {
return {
beforeFiles: [
{
source: '/api/search/:path*',
destination: `${BACKEND_URL}/api/search/:path*`,
},
],
fallback: [
{
source: '/api/:path*',
destination: `${BACKEND_URL}/api/:path*`,
},
],
};
},
};
const withPWA = pwaPlugin({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
});
const withBundleAnalyzer = bundleAnalyzerPlugin({
enabled: process.env.ANALYZE === 'true',
});
const withNextIntl = createNextIntlPlugin();
/**
* @type {import('@pigment-css/nextjs-plugin').PigmentOptions}
*/
const pigmentConfig = {
transformLibraries: ['@mui/material'],
theme: extendTheme({
colorSchemes: {
dark: {
palette: {
error: {
main: '#ff1744',
},
contrastThreshold: 3,
tonalOffset: 0.2,
},
},
light: {
palette: {
error: {
main: '#ff1744',
},
contrastThreshold: 3,
tonalOffset: 0.2,
},
},
},
components: {
MuiInputLabel: {
styleOverrides: {
root: {
fontWeight: 500,
},
},
},
MuiTooltip: {
styleOverrides: {
tooltip: {
fontSize: '13px',
},
},
},
},
}),
};
export default withPigment(
withNextIntl(
withPWA(
withBundleAnalyzer(
withSentryConfig(
nextConfig,
/** @type {import('@sentry/nextjs').SentryWebpackPluginOptions} */
{
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
widenClientFileUpload: true,
hideSourceMaps: true,
disableLogger: process.env.NODE_ENV === 'production',
finalize: false,
},
{
hideSourceMaps: true,
},
),
),
),
),
pigmentConfig,
); |
I think the issue here is related to
using
However, there is still FOUC flickering when specifying dark mode, but that's another issue... |
Thanks, @abriginets, for the report and @samuelgoldenbaum, for replying. The guide has already been fixed to replace @abriginets can you confirm if the following change on your config file solves your issue: import bundleAnalyzerPlugin from '@next/bundle-analyzer';
-import { extendTheme, withPigment } from '@pigment-css/nextjs-plugin';
+import {withPigment } from '@pigment-css/nextjs-plugin';
+import { createTheme } from '@mui/material/styles';
import { withSentryConfig } from '@sentry/nextjs';
// ...
// ...
const pigmentConfig = {
transformLibraries: ['@mui/material'],
- theme: extendTheme({
+ theme: createTheme({
colorSchemes: {
// ... |
@DiegoAndai yep, that does fix the issue with spacing and breakpoints, I can confirm there are no such errors now in the terminal. |
Thanks @abriginets, I'm closing the issue as it has been fixed and the migration guide updated. If you have a similar issue, please open a new one with a repro. |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note We value your feedback @abriginets! How was your experience with our support team? |
I encountered the follwoing: import { useTheme } from '@mui/material-pigment-css';
const theme = useTheme();
theme.spacing // undefined import { useTheme } from '@mui/material/styles';
const theme = useTheme();
theme.spacing // function Vite Config: import process from 'process';
import { createTheme } from '@mui/material';
import { PigmentOptions, pigment } from '@pigment-css/vite-plugin';
import legacy from '@vitejs/plugin-legacy';
import react from '@vitejs/plugin-react-swc';
import path from 'path';
import { defineConfig } from 'vite';
import { version } from './package.json';
const pigmentConfig: PigmentOptions = {
theme: createTheme({ cssVariables: true }),
transformLibraries: ['@mui/material'],
};
export default defineConfig(() => ({
plugins: [
pigment(pigmentConfig),
react({ jsxImportSource: '@emotion/react' }),
],
})); Tried to set up a minimal Code Sandbox, but it's crashing when I import the useTheme. :/ |
Hey @bmakan, may I ask you to open a separate issue about this? |
Related page
https://mui.com/material-ui/migration/migrating-to-pigment-css/
Kind of issue
Missing information
Issue description
I just upgraded to MUI v6 and started migrating to pigment, followed all the steps in the docs and now there are errors when I'm trying to start dev server
Although on mui/pigment-css#creating-styles it does provide and example of how spacing should be used with pigment, i.e.
Should this be a part of migration docs and marked as breaking change? As for
breakpoints
, I couldn't find mentioning it anywhere except for mui/pigment-css#203. Response suggests we need to set breakpoints explicitly now. Not sure if that's a bug or an undocumented breaking change, we were using default MUI breakpoints since day one.Context
Migrating to pigment-css in NextJS + MUIv6
Search keywords: pigment
The text was updated successfully, but these errors were encountered: