mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
chore(next): refactor nextjs config to mjs
remove husky
This commit is contained in:
95
next.config.mjs
Normal file
95
next.config.mjs
Normal file
@ -0,0 +1,95 @@
|
||||
// import NextBundleAnalyzer from '@next/bundle-analyzer';
|
||||
//
|
||||
// const withBundleAnalyzer = NextBundleAnalyzer({
|
||||
// enabled: process.env.ANALYZE === 'true',
|
||||
// });
|
||||
|
||||
/**
|
||||
* @type {import('next').NextConfig}
|
||||
*/
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
swcMinify: true,
|
||||
output: 'standalone',
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: '**',
|
||||
},
|
||||
],
|
||||
},
|
||||
experimental: {
|
||||
webpackBuildWorker: true,
|
||||
mdxRs: true,
|
||||
},
|
||||
compiler: {
|
||||
removeConsole: process.env.NODE_ENV === 'production',
|
||||
},
|
||||
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
|
||||
webpack(config, { isServer }) {
|
||||
if (!isServer) {
|
||||
// We're in the browser build, so we can safely exclude the sharp module
|
||||
config.externals.push('sharp');
|
||||
}
|
||||
// audio support
|
||||
config.module.rules.push({
|
||||
test: /\.(ogg|mp3|wav|mpe?g)$/i,
|
||||
exclude: config.exclude,
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve('url-loader'),
|
||||
options: {
|
||||
limit: config.inlineImageLimit,
|
||||
fallback: require.resolve('file-loader'),
|
||||
publicPath: `${config.assetPrefix}/_next/static/images/`,
|
||||
outputPath: `${isServer ? '../' : ''}static/images/`,
|
||||
name: '[name]-[hash].[ext]',
|
||||
esModule: config.esModule || false,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// shader support
|
||||
config.module.rules.push({
|
||||
test: /\.(glsl|vs|fs|vert|frag)$/,
|
||||
exclude: /node_modules/,
|
||||
use: ['raw-loader', 'glslify-loader'],
|
||||
});
|
||||
|
||||
return config;
|
||||
},
|
||||
};
|
||||
|
||||
const KEYS_TO_OMIT = [
|
||||
'webpackDevMiddleware',
|
||||
'configOrigin',
|
||||
'target',
|
||||
'analyticsId',
|
||||
'webpack5',
|
||||
'amp',
|
||||
'assetPrefix',
|
||||
];
|
||||
|
||||
export default function finalConfig(_phase, { defaultConfig }) {
|
||||
// const plugins = [[withBundleAnalyzer, {}]];
|
||||
const plugins = [[(config) => config, {}]];
|
||||
|
||||
const wConfig = plugins.reduce(
|
||||
(acc, [plugin, config]) => plugin({ ...acc, ...config }),
|
||||
{
|
||||
...defaultConfig,
|
||||
...nextConfig,
|
||||
},
|
||||
);
|
||||
|
||||
const finalConfig = {};
|
||||
Object.keys(wConfig).forEach((key) => {
|
||||
if (!KEYS_TO_OMIT.includes(key)) {
|
||||
finalConfig[key] = wConfig[key];
|
||||
}
|
||||
});
|
||||
|
||||
return finalConfig;
|
||||
}
|
Reference in New Issue
Block a user