-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathnext.config.js
74 lines (67 loc) · 1.89 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const sass = require('@zeit/next-sass');
// const webpack = require('webpack');
const Dotenv = require('dotenv-webpack');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const path = require('path');
const graphql = require('next-plugin-graphql');
const images = require('next-optimized-images');
const { withPlugins } = require('next-compose-plugins');
const analyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const { NODE_ENV, CUSTOM_ENV } = require('./config/config');
const nextConfig = {
webpack: (config) => {
const enhancedConfig = config;
enhancedConfig.node = {
fs: 'empty',
};
enhancedConfig.plugins.push(...[
new Dotenv({
path: path.join(__dirname, `/secrets/${NODE_ENV}-${CUSTOM_ENV}.env`), // Path to .env file (this is the default)
// safe: true // load .env.example (defaults to "false" which does not use dotenv-safe)
}),
new SWPrecacheWebpackPlugin({
verbose: true,
staticFileGlobsIgnorePatterns: [/\.next\//],
runtimeCaching: [
{
handler: 'networkFirst',
urlPattern: /^https?.*/,
},
],
}),
// new webpack.ContextReplacementPlugin(
// /graphql-language-service-interface[\\/]dist$/,
// new RegExp('^\\./.*\\.js$'),
// ),
]);
if (NODE_ENV === 'development') {
enhancedConfig.devtool = 'cheap-module-source-map';
}
enhancedConfig.resolve.extensions = config.resolve.extensions.concat([
'.ts',
'.tsx',
]);
return config;
},
};
const config = withPlugins(
[
[
sass,
{
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: '[local]___[hash:base64:5]',
},
},
],
graphql,
images,
analyzer,
],
nextConfig,
);
module.exports = config;