-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
51 lines (43 loc) · 1.21 KB
/
webpack.config.js
File metadata and controls
51 lines (43 loc) · 1.21 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: `${__dirname}/app/index.html`,
filename: 'index.html',
inject: 'body',
});
const webpack = require('webpack');
const noEnvVar = (name) => {
throw new Error(`${name} environment variable is undefined. Please provide it to fix this error.`);
};
const DefinePluginConfig = new webpack.DefinePlugin({
COGNITO_POOL_ID: JSON.stringify(process.env.COGNITO_POOL_ID || noEnvVar('COGNITO_POOL_ID')),
COGNITO_APP_CLIENT_ID: JSON.stringify(process.env.COGNITO_APP_CLIENT_ID || noEnvVar('COGNITO_APP_CLIENT_ID')),
});
const BabelLoader = {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
};
const CSSLoader = {
test: /\.css$/,
loader: 'style-loader!css-loader?modules!postcss-loader',
};
const JSONLoader = {
test: /\.json$/,
loader: 'json-loader',
};
module.exports = {
entry: [
'./app/index.js',
],
output: {
path: `${__dirname}/dist`,
filename: 'index_bundle.js',
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
loaders: [BabelLoader, CSSLoader, JSONLoader],
},
plugins: [HtmlWebpackPluginConfig, DefinePluginConfig],
};