Skip to content

Commit

Permalink
fix: Enhance CSS handling in Next.js configuration and adjust import …
Browse files Browse the repository at this point in the history
…order for global styles
  • Loading branch information
szweibel committed Dec 18, 2024
1 parent fe63b8b commit 681e040
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
15 changes: 10 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const { default: next } = require('next');
const withMDX = require('@next/mdx')({
extension: /\.(md|mdx)$/,
Expand All @@ -13,17 +12,23 @@ process.env.NEXT_PUBLIC_ASSET_PREFIX = process.env.PAGES_PATH || '';

const nextConfig = {
output: "export",
// trailingSlash: true,
// basePath: process.env.PAGES_PATH || '',
images: {
unoptimized: true,
},
// Add CSS optimization
experimental: {
optimizeCss: true,
optimizeCss: true, // Enable CSS optimization
},
webpack(config) {
// CSS handling
config.module.rules.push({
test: /\.css$/,
use: ['style-loader', 'css-loader']
});
return config;
}
}

console.log(nextConfig);


module.exports = nextConfig;
9 changes: 5 additions & 4 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState, useRef } from 'react';
import Head from 'next/head';
// MUI styles first

// MUI base
import CssBaseline from '@mui/material/CssBaseline';
import { StyledEngineProvider } from '@mui/material/styles';

Expand All @@ -9,16 +10,16 @@ import 'highlight.js/styles/obsidian.css';
import 'allotment/dist/style.css';
import 'react-medium-image-zoom/dist/styles.css';

// Global styles last to override
import '../styles/styles.scss';

// Framework imports
import dynamic from 'next/dynamic';
import { ThemeProvider } from 'next-themes';
import { SWRConfig, useSWRConfig } from 'swr';
import { useRouter } from 'next/router';
import { GitHubProvider } from '../components/GitHubContext';

// Custom styles last
import '../styles/styles.scss';

const Footer = dynamic(() => import('../components/Footer'));

function MyApp({ Component, pageProps }) {
Expand Down

0 comments on commit 681e040

Please sign in to comment.