-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnext.config.js
36 lines (33 loc) · 1.2 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
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const Webpack = require('webpack');
const withTypescript = require('@zeit/next-typescript');
const packageJSON = require('./package.json');
const { ANALYZE, NODE_ENV } = process.env;
const API = NODE_ENV === 'development' ? packageJSON.config.API_DEV : packageJSON.config.API;
module.exports = withTypescript({
webpack(config, options) {
// const { dir, defaultLoaders, dev, isServer } = options;
if (ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true
}));
}
config.plugins.push(
new Webpack.DefinePlugin({
'APP_VERSION': JSON.stringify(packageJSON.version),
'API': JSON.stringify(API),
'OLD_DATAHUB_URL': JSON.stringify(packageJSON.config.OLD_DATAHUB_URL)
}));
config.plugins.push(new ForkTsCheckerWebpackPlugin());
config.module.noParse = /mapbox-gl/;
config.devtool = 'cheap-source-map';
return config;
},
typescriptLoaderOptions: {
transpileOnly: true
}
});