-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgetBaseConfig.js
More file actions
148 lines (140 loc) · 4.51 KB
/
getBaseConfig.js
File metadata and controls
148 lines (140 loc) · 4.51 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const FailPlugin = require('webpack-fail-plugin');
const mergeSassFeatureConfig = require('./features/sass');
const mergeLessFeatureConfig = require('./features/less');
const mergeCssFeatureConfig = require('./features/css');
const mergeFontsFeatureConfig = require('./features/fonts');
const mergeImagesFeatureConfig = require('./features/images');
const mergeEs7FeatureConfig = require('./features/es7');
const stats = {
// Add asset Information
assets: false,
// Sort assets by a field
assetsSort: "field",
// Add information about cached (not built) modules
cached: true,
// Show cached assets (setting this to `false` only shows emitted files)
cachedAssets: false,
// Add children information
children: true,
// Add chunk information (setting this to `false` allows for a less verbose output)
chunks: false,
// Add built modules information to chunk information
chunkModules: false,
// Add the origins of chunks and chunk merging info
chunkOrigins: false,
// Sort the chunks by a field
chunksSort: "field",
// Context directory for request shortening
// context: "../src/",
// `webpack --colors` equivalent
colors: true,
// Display the distance from the entry point for each module
depth: false,
// Display the entry points with the corresponding bundles
entrypoints: false,
// Add errors
errors: true,
// Add details to errors (like resolving log)
errorDetails: true,
// Exclude assets from being displayed in stats
// This can be done with a String, a RegExp, a Function getting the assets name
// and returning a boolean or an Array of the above.
// excludeAssets: ,
// Exclude modules from being displayed in stats
// This can be done with a String, a RegExp, a Function getting the modules source
// and returning a boolean or an Array of the above.
// excludeModules: ,
// See excludeModules
// exclude: ,
// Add the hash of the compilation
hash: true,
// Set the maximum number of modules to be shown
maxModules: 5,
// Add built modules information
modules: false,
// Sort the modules by a field
modulesSort: "field",
// Show dependencies and origin of warnings/errors (since webpack 2.5.0)
moduleTrace: true,
// Show performance hint when file size exceeds `performance.maxAssetSize`
performance: false,
// Show the exports of the modules
providedExports: false,
// Add public path information
publicPath: true,
// Add information about the reasons why modules are included
reasons: true,
// Add the source code of modules
source: true,
// Add timing information
timings: true,
// Show which exports of a module are used
usedExports: false,
// Add webpack version information
version: true,
// Add warnings
warnings: true,
// Filter warnings to be shown (since webpack 2.4.0),
// can be a String, Regexp, a function getting the warning and returning a boolean
// or an Array of a combination of the above. First match wins.
// warningsFilter
};
module.exports = ({ projectRootDirectory, isDevServer = false }) => {
const plugins = [
new webpack.optimize.ModuleConcatenationPlugin(),
new ExtractTextPlugin(
{
filename: '[name].css',
disable: isDevServer,
}
),
new webpack.EnvironmentPlugin({ NODE_ENV: 'production' }),
FailPlugin,
];
if (process.env.NODE_ENV !== 'development') {
plugins.push(
new UglifyJsPlugin(
{
parallel: true,
}
)
);
plugins.push(
new webpack.optimize.AggressiveMergingPlugin()
);
}
let baseConfig = {
devtool: false,
node: { fs: 'empty' }, // workaround bug in css-loader
plugins,
stats,
devServer: {
stats,
},
resolveLoader: {
modules: [
'node_modules',
'./node_modules/re-app-builder/node_modules',
],
},
resolve: {
modules: [
'node_modules',
...(isDevServer ? [
path.resolve(projectRootDirectory, 'node_modules')
] : [])
],
},
};
baseConfig = mergeSassFeatureConfig({ baseConfig, isDevServer, projectRootDirectory });
baseConfig = mergeLessFeatureConfig({ baseConfig, isDevServer, projectRootDirectory });
baseConfig = mergeCssFeatureConfig({ baseConfig, isDevServer, projectRootDirectory });
baseConfig = mergeFontsFeatureConfig({ baseConfig, isDevServer, projectRootDirectory });
baseConfig = mergeImagesFeatureConfig({ baseConfig, isDevServer, projectRootDirectory });
baseConfig = mergeEs7FeatureConfig({ baseConfig, isDevServer, projectRootDirectory });
return baseConfig;
};