-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
65 lines (63 loc) · 2.18 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
56
57
58
59
60
61
62
63
64
65
/* eslint-disable no-console */
/* eslint-disable global-require */
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
module.exports = (env, argv) => {
const isProd = argv.mode === 'production';
const APP_DIR = path.resolve('./src');
return {
mode: isProd ? 'production' : 'development',
entry: {
main: path.resolve(APP_DIR, 'index.js'),
},
output: {
path: path.resolve(__dirname, './dist'),
filename: isProd ? '[name].[contenthash].js' : '[name].js',
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
},
{
test: /\.(js|jsx)$/,
include: [path.resolve(__dirname, 'src')],
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: ['last 1 version', 'ie >= 11'],
},
],
'@babel/preset-react',
],
plugins: ['@babel/plugin-transform-runtime'],
},
},
],
},
],
},
devtool: 'source-map',
plugins: [
new HtmlWebPackPlugin({
filename: 'index.html',
template: 'src/index.html',
scriptLoading: 'defer',
globalConstants: {
BUNGIE_APP_ID: '34894',
BUNGIE_API_KEY: 'a4bb5c8feec940eeb7d8167fda39e31b',
VERSION: '0.0.1',
PRODUCTION: isProd,
},
}),
],
};
};