rsnext/test/integration/config/next.config.js
Tim Neutkens e1502bc9a5
Enable webpack5 for all apps (#25639)
* Enable webpack 5 by default for all apps

Still provides a way to opt-out using `webpack5: false` in next.config.js. Also throws an error for `future.webpack5`.

* Update tests

* Update test to run on webpack 4 instead of webpack 5

* disable webpack5 for legacy tests

* Fix stats-config for webpack4

* update tests

* update size for webpack4 test

* move basic suite first

* update basic test

* Add logs

* remove outdated testFutureDependencies job

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-06-07 15:48:29 -05:00

55 lines
1.5 KiB
JavaScript

const withCSS = require('@zeit/next-css')
const withSass = require('@zeit/next-sass')
const path = require('path')
module.exports = withCSS(
withSass({
// @zeit/next-sass is not supported with webpack 5
webpack5: false,
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60,
},
poweredByHeader: false,
cssModules: true,
serverRuntimeConfig: {
mySecret: 'secret',
},
publicRuntimeConfig: {
staticFolder: '/static',
},
env: {
customVar: 'hello',
},
webpack(config, { dev, buildId, webpack }) {
if (dev) {
if (config.bail !== false) {
throw new Error('Wrong bail value for development!')
}
} else {
if (config.bail !== true) {
throw new Error('Wrong bail value for production!')
}
}
// When next-css is `npm link`ed we have to solve loaders from the project root
const nextLocation = path.join(
require.resolve('next/package.json'),
'../'
)
const nextCssNodeModulesLocation = path.join(
require.resolve('@zeit/next-css'),
'../../../node_modules'
)
if (nextCssNodeModulesLocation.indexOf(nextLocation) === -1) {
config.resolveLoader.modules.push(nextCssNodeModulesLocation)
}
config.plugins.push(
new webpack.DefinePlugin({
'process.env.CONFIG_BUILD_ID': JSON.stringify(buildId),
})
)
return config
},
})
)