Files
app/nextjs/next.config.js
T
2019-10-14 11:15:18 +02:00

90 lines
2.5 KiB
JavaScript

// next.config.js
const withPlugins = require('next-compose-plugins')
const optimizedImages = require('next-optimized-images')
const webpack = require("webpack")
const withCSS = require('@ostai/next-css')
const withOffline = require('next-offline')
const Dotenv = require('dotenv-webpack');
const { ANALYZE, DEV } = process.env
module.exports = withPlugins(
[
[withCSS],
[optimizedImages, {
/* config for next-optimized-images */
}],
[withOffline, {
dontAutoRegisterSw: DEV ? true : false,
workboxOpts: {
runtimeCaching: [
// { urlPattern: /.*auth.*/, handler: 'networkOnly' },
// { urlPattern: /.*account.*/, handler: 'networkOnly' },
{ urlPattern: /^https?.*/, handler: 'NetworkFirst' },
{
urlPattern: /\.(?:png|jpg|jpeg|svg|webp)$/,
handler: "CacheFirst",
options: {
cacheName: "images",
expiration: {
maxEntries: 100
}
}
}
],
importScripts:
['/static/js/Edeclic-service-worker.js',
'/static/js/backgroundSync-sw.js'
]
},
}],
[{
publicRuntimeConfig: {
symphonyUrl: 'https://www.talentstube.com',
frontServerUrl: 'https://pp.app.talentstube.com',
adListDefaultUrl: '/static/images/default/default_picture_company.svg',
cachedMediaUrl: '/media/cache/profile_thumb/uploads/img/',
postedContentUrl: '/uploads/img/',
}
}]
],
{
webpack: (config, { isServer }) => {
if (ANALYZE) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true
}))
}
const videojsPlugin = new webpack.ProvidePlugin({
videojs: "video.js/dist/video.cjs.js",
RecordRTC: "recordrtc",
MediaStreamRecorder: ["recordrtc", "MediaStreamRecorder"]
});
const videojsAlias = {
videojs: "video.js",
WaveSurfer: "wavesurfer.js",
RecordRTC: "recordrtc"
};
config.resolve.alias = { ...config.resolve.alias, ...videojsAlias };
config.plugins.push(videojsPlugin);
config.plugins.push(new Dotenv());
return config
}
},
{
generateBuildId: async () => {
// For example get the latest git commit hash here
return 'v0.1.0'
}
},
);