-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathnext.config.js
More file actions
63 lines (60 loc) · 2.12 KB
/
Copy pathnext.config.js
File metadata and controls
63 lines (60 loc) · 2.12 KB
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
/* eslint-disable no-param-reassign */
const { IgnorePlugin } = require('webpack');
const Dotenv = require('dotenv-webpack');
const path = require('path');
const withTM = require('next-transpile-modules');
const dedupeDependencies = (dependencies, alias) => (
dependencies.reduce((res, dependecy) => ({
...res, [dependecy]: path.resolve(`./node_modules/${dependecy}`),
}), alias)
);
const initExport = {
// eslint-disable-next-line no-unused-vars
webpack: (config, env) => {
config.plugins.push(new Dotenv({
path: './.env',
}));
config.plugins.push(new IgnorePlugin(/^\.\/locale$/, /moment$/));
if (process.env.ANALYZE_BUILD) {
// eslint-disable-next-line global-require
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true,
}),
);
}
if (process.env.NODE_ENV === 'alias') {
config.resolve.alias = dedupeDependencies(
['@babel', 'styled-components', 'grommet', 'grommet-icons', 'react', 'react-dom', 'polished'], config.resolve.alias,
);
}
if (process.env.NODE_ENV === 'dx-grid') {
config.resolve.alias = dedupeDependencies(
['@babel', '@devexpress', 'styled-components', 'grommet', 'grommet-controls', 'grommet-icons', 'react', 'react-dom', 'polished'], config.resolve.alias,
);
}
if (process.env.NODE_ENV === 'grommet') {
config.resolve.alias = dedupeDependencies(
['@babel', 'styled-components', 'grommet-icons', 'react', 'react-dom', 'polished'], config.resolve.alias,
);
}
return config;
},
};
if (process.env.NODE_ENV === 'alias') {
initExport.transpileModules = ['grommet-controls'];
}
if (process.env.NODE_ENV === 'grommet') {
initExport.transpileModules = ['grommet'];
}
if (process.env.NODE_ENV === 'dx-grid') {
initExport.transpileModules = ['dx-react-grid-grommet'];
}
if (['alias', 'grommet', 'dx-grid'].indexOf(process.env.NODE_ENV) >= 0) {
module.exports = withTM(initExport);
} else {
module.exports = initExport;
}