-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
41 lines (39 loc) · 1.19 KB
/
webpack.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = (env) => {
// create a nice object from the env variable
const envKeys = Object.keys(env).reduce((prev, next) => {
prev[`process.env.${next}`] = JSON.stringify(env[next]);
return prev;
}, {});
return{
entry: './src/index.js',
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js'
},
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
use: { loader: 'file-loader'}
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.js$/i,
exclude: /node_modules/,
use: { loader: 'babel-loader' }
}
]
},
plugins: [
new webpack.DefinePlugin(envKeys),
new HtmlWebpackPlugin({ template: './src/index.html' })
]
}
}