-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.common.config.js
69 lines (61 loc) · 1.54 KB
/
webpack.common.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
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const envConfig = require('./src/config/envConfig');
function stringifyValues(obj) {
return Object.keys(obj).reduce((acc, key) => {
const value = obj[key];
if (value === null) {
acc[key] = value;
} else if (typeof value === 'object') {
acc[key] = stringifyValues(value);
} else {
acc[key] = JSON.stringify(value);
}
return acc;
}, {});
}
module.exports = {
output: {
publicPath: '/',
},
module: {
rules: [
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/redux-form'),
],
loader: 'babel-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
new webpack.DefinePlugin(stringifyValues(envConfig.getEnvironmentSpecificConfig())),
new HtmlWebpackPlugin({
template: 'src/client/index.html',
minify: {
minifyCSS: true,
collapseWhitespace: true,
preserveLineBreaks: false,
},
}),
new CopyWebpackPlugin([
{
from: 'src/client/assets/',
to: 'assets/',
},
{
from: `src/config/robots${envConfig.getEnvKey() === 'production' ? '_prod' : ''}.txt`,
to: 'robots.txt',
},
]),
],
};