Created
September 27, 2019 14:41
-
-
Save cryptiklemur/ea3ddc822b6f0b35abf53c908b696228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {ContextReplacementPlugin} = require('webpack'); | |
const {join} = require('path'); | |
require('dotenv').config({path: join(__dirname, '.env.build')}); | |
const withImages = require('next-images'); | |
const withSass = require('@zeit/next-sass'); | |
const withSourcemaps = require('@zeit/next-source-maps')(); | |
const isProd = process.env.NODE_ENV === 'production'; | |
const ident = isProd ? '[hash:base64:5]_[local:base64:5]' : '[name]_[local]'; | |
const env = { | |
sfw: process.env.SFW === 'true', | |
PORT: process.env.PORT || '3000', | |
dev: !isProd, | |
base_dir: process.env.BASE_DIR || __dirname, | |
google_maps_api_key: process.env.GMAPS_KEY, | |
sentry_dsn: process.env.SENTRY_DSN || false, | |
vm: process.env.VM === 'true', | |
transient: process.env.TRANSIENT === 'true', | |
image_cdn: process.env.IMAGE_CDN, | |
api_base_uri: process.env.API_URL, | |
myeplay_base_uri: process.env.MYEPLAY_URL, | |
lively_base_uri: process.env.LIVELY_URL || 'https://eplay-dev.livelyvideo.tv', | |
rng_base_uri: process.env.RNG_URL, | |
search_base_uri: process.env.SEARCH_URL, | |
session_domain: process.env.SESSION_DOMAIN, | |
environment: process.env.ENVIRONMENT, | |
buildId: process.env.BUILD_ID, | |
}; | |
class FilterPlugin { | |
constructor(options) { | |
this.options = options; | |
} | |
apply(compiler) { | |
compiler.hooks.afterEmit.tap( | |
'FilterPlugin', | |
(comp) => { | |
comp.warnings = comp.warnings.filter((warning) => !this.options.filter.test(warning.message)); | |
}, | |
); | |
} | |
} | |
module.exports = withSourcemaps(withImages(withSass({ | |
cssLoaderOptions: { | |
camelCase: true, | |
importLoaders: 1, | |
localIdentName: ident, | |
}, | |
experimental: {publicDirectory: true}, | |
cssModules: true, | |
env, | |
target: 'serverless', | |
generateBuildId: () => env.buildId, | |
webpack(config, nextConfig) { | |
config.resolve.alias = { | |
...config.resolve.alias, | |
...require('./webpack.config').resolve.alias, | |
}; | |
if (!nextConfig.isServer) { | |
config.plugins.push( | |
new FilterPlugin({filter: /chunk styles \[mini-css-extract-plugin]\nConflicting order between:/}), | |
new ContextReplacementPlugin( | |
/moment[/\\]locale$/, | |
/en|fr|de|es/, | |
), | |
); | |
} | |
// Necessary for file changes inside the bind mount to get picked up | |
config.watchOptions = {aggregateTimeout: 300, poll: 1000}; | |
return config; | |
}, | |
}))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment