@moxy/next-common-files
Version:
Next.js plugins that configure webpack with loaders for common files.
30 lines (25 loc) • 908 B
JavaScript
;
module.exports = (userOptions = {}) => (nextConfig = {}) => ({
...nextConfig,
webpack(config, options) {
const { assetPrefix = '' } = nextConfig;
const { dev, isServer } = options;
config.module.rules.push({
test: /\.(eot|ttf|woff|woff2|otf)$/,
loader: require.resolve('url-loader'),
...userOptions,
options: {
limit: 0,
name: dev ? '[path][name].[ext]' : 'fonts/[name].[contenthash:20].[ext]',
publicPath: `${assetPrefix}/_next/static/chunks/media`,
outputPath: 'static/chunks/media',
emitFile: !isServer,
...userOptions.options,
},
});
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options);
}
return config;
},
});