2021-01-09 17:50:45 +08:00
|
|
|
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
|
|
|
enabled: process.env.ANALYZE === 'true',
|
|
|
|
})
|
|
|
|
|
|
|
|
module.exports = withBundleAnalyzer({
|
2021-04-11 18:56:11 -05:00
|
|
|
reactStrictMode: true,
|
2021-01-09 17:50:45 +08:00
|
|
|
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
|
2021-06-23 18:32:29 +08:00
|
|
|
eslint: {
|
|
|
|
dirs: ['pages', 'components', 'lib', 'layouts', 'scripts'],
|
2021-01-09 17:50:45 +08:00
|
|
|
},
|
2021-08-14 23:11:18 +08:00
|
|
|
experimental: { esmExternals: true },
|
2021-01-09 17:50:45 +08:00
|
|
|
webpack: (config, { dev, isServer }) => {
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.(png|jpe?g|gif|mp4)$/i,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
publicPath: '/_next',
|
|
|
|
name: 'static/media/[name].[hash].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: ['@svgr/webpack'],
|
|
|
|
})
|
|
|
|
|
|
|
|
if (!dev && !isServer) {
|
|
|
|
// Replace React with Preact only in client production build
|
|
|
|
Object.assign(config.resolve.alias, {
|
|
|
|
react: 'preact/compat',
|
|
|
|
'react-dom/test-utils': 'preact/test-utils',
|
|
|
|
'react-dom': 'preact/compat',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
},
|
|
|
|
})
|