favycon/next.config.js
Rui Saraiva b183cc9fef
feat: setup next, eslint, stylelint, and typescript (#5)
* feat: setup next, eslint, stylelint, and typescript

* ci: add Semantic Pull Requests config

* ci: add renovate config

* ci: add commit lint workflow

* ci: add code lint workflow

* ci: add release workflow

* docs(ci): add status badges for release, lint, and commitlint

* ci: add now config

* chore: update repo name

* ci(release): remove assets from release
2020-04-10 22:34:32 +01:00

50 lines
1.3 KiB
JavaScript

const path = require('path')
require('dotenv').config()
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
experimental: {
modern: true,
polyfillsOptimization: true,
},
webpack(config, { dev, isServer }) {
const splitChunks = config.optimization && config.optimization.splitChunks
if (splitChunks) {
const { cacheGroups } = splitChunks
const preactModules = /[\\/]node_modules[\\/](preact|preact-render-to-string|preact-context-provider)[\\/]/
if (cacheGroups.framework) {
cacheGroups.preact = { ...cacheGroups.framework, test: preactModules }
cacheGroups.commons.name = 'framework'
} else {
cacheGroups.preact = {
name: 'commons',
chunks: 'all',
test: preactModules,
}
}
}
config.resolve.alias['components'] = path.join(__dirname, 'components')
config.resolve.alias['hooks'] = path.join(__dirname, 'hooks')
config.resolve.alias['react'] = 'preact/compat'
config.resolve.alias['react-dom'] = 'preact/compat'
config.resolve.alias['react-ssr-prepass'] = 'preact-ssr-prepass'
// inject Preact DevTools
if (dev && !isServer) {
const { entry } = config
config.entry = () =>
entry().then((entries) => {
entries['main.js'] = ['preact/debug'].concat(entries['main.js'] || [])
return entries
})
}
return config
},
poweredByHeader: !isProduction,
}