-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (50 loc) · 1.23 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* eslint-disable global-require */
const path = require('path');
const webpack = require('webpack');
const WebpackNotifierPlugin = require('webpack-notifier');
const merge = require('webpack-merge');
const env = process.env.NODE_ENV;
const common = {
// context: __dirname,
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js',
},
entry: [
'babel-polyfill',
'./src',
],
resolve: {
extensions: ['.js'],
},
plugins: [
new WebpackNotifierPlugin({
excludeWarnings: true,
}),
],
module: {
rules: [
// Loads JS files and enables us to transpile our JSX /
// ES2015+ code to make it browser friendly.
{
test: /\.js$/,
exclude: /node_modules/,
use: { loader: 'babel-loader' },
},
],
},
};
const merged = conf => merge(common, conf);
console.log(`running ${env} webpack config!`);
// here we merge our webpack configuration files depending on the environment
switch (env) {
case 'development':
module.exports = merged(require('./webpack/webpack.dev.config'));
break;
case 'production':
console.log('prod');
module.exports = merged(require('./webpack/webpack.prod.config'));
break;
default:
break;
}