next-haskell/src/index.js

30 lines
719 B
JavaScript
Raw Normal View History

2023-07-03 15:35:27 -04:00
module.exports = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack(config, options) {
if (!options.defaultLoaders) {
throw new Error(
'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade'
);
}
2023-07-03 15:55:36 -04:00
const { dir, dev, isServer } = options;
2023-07-03 15:35:27 -04:00
config.module.rules.push({
test: /\.(cabal)$/,
use: [
{
loader: 'haskell-loader',
2023-07-03 15:55:36 -04:00
options: { dev, isServer },
2023-07-03 15:35:27 -04:00
},
],
});
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
} else {
return config;
}
},
})
}