Files
shields/next.config.js
Paul Melnikow 3a7bddbc26 Consolidate service definition schema, removing support for previewUrl (#2895)
This removes `LONG_CACHE` and its descendants, which was a feature that added `?maxAge` to the live preview badges in the frontend. Since they are all static that is no longer needed, as the static badges all have longer cache timeouts regardless.
2019-01-30 18:35:11 -06:00

48 lines
1.2 KiB
JavaScript

'use strict'
const envFlag = require('node-env-flag')
const webpack = require('webpack')
const shouldAnalyze = envFlag(process.env.ANALYZE)
const assetPrefix = process.env.NEXT_ASSET_PREFIX
module.exports = {
webpack: config => {
config.plugins.push(new webpack.EnvironmentPlugin({ BASE_URL: null }))
if (shouldAnalyze) {
// We don't include webpack-bundle-analyzer in devDependencies, so load
// lazily.
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true,
})
)
}
config.module.rules.push({
test: /\.yml$/,
use: {
loader: 'js-yaml-loader',
},
})
if (assetPrefix) {
config.output.publicPath = `${assetPrefix}/${config.output.publicPath}`
}
return config
},
exportPathMap: () => ({
'/': { page: '/' },
}),
}
// Avoid setting an `undefined` value. This causes
// `TypeError: Cannot read property 'replace' of undefined` at build time.
if (assetPrefix) {
module.exports.assetPrefix = assetPrefix
}