-
Notifications
You must be signed in to change notification settings - Fork 12
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
How to do with a custom next.config.js #36
Comments
@rahul3103 rahul3103 You can achieve this by extending the next.config you posted. I ran across this because I was trying to use the same type of @cyrilwanner Could you clarify how to reproduce the phase logic detailed in this next example using next-compose-plugins syntax? Thank you! |
The extending thing didn't quite work for me so I ended up writing my config like another plugin const withPlugins = require('next-compose-plugins');
const optimizedImages = require('next-optimized-images');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const siteMap = require('./scripts/sitemap'); // this is just a plain node script
function ourConfig(nextConfig = {}) {
// can do logic that doesn't depend on webpack config or options here
return Object.assign({}, nextConfig, {
webpack(config, options) {
// logic that depends on config/options here
if (options.isServer) {
siteMap({
// use globby patters to full path inside `/src`
exclude: ['!pages/temp-page.js'],
});
}
// I needed to add a way to raw load markdown files so I can process them with remark
config.module.rules.push({
test: /\.md$/,
loader: 'raw-loader',
});
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options);
}
return config;
},
});
}
module.exports = withPlugins([
[withBundleAnalyzer({})],
[ourConfig()],
[
optimizedImages,
{
responsive: {
adapter: require('responsive-loader/sharp'),
},
pngquant: {
speed: 10,
},
},
],
]); |
I wanted to find a way to use the phase inside my function getNextConfig(phase) {
return {
// ...
}
}
module.exports = (phase, ...rest) => {
const nextConfig = getNextConfig(phase);
return withPlugins(plugins, nextConfig)(phase, ...rest);
}; |
How can i use next-compose-plugins here?
The text was updated successfully, but these errors were encountered: