forked from TyVik/geopuzzle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
82 lines (77 loc) · 1.96 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
const webpack = require('webpack');
const path = require('path');
const SentryCliPlugin = require('@sentry/webpack-plugin');
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();
module.exports = (env, argv) => {
const NODE_ENV = process.env.NODE_ENV || 'development';
let result = {
context: __dirname + '/frontend',
entry: {
index: './index',
games: './games',
workshop: './workshop',
profile: './profile',
},
output: {
path: path.resolve(__dirname, 'static', 'js'),
filename: "[name].js",
sourceMapFilename: "[name].map",
},
resolve: {
extensions: ['.js', '.jsx'],
},
watchOptions: {
aggregateTimeout: 100
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
process: {
env: {
NODE_ENV: JSON.stringify(NODE_ENV)
}
}
}),
],
module: {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ['babel-loader']
}, {
test: /\.css$/,
exclude: /node_modules/,
use: ['style-loader', 'css-loader']
}]
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /node_modules\/(?!html2canvas)/,
chunks: 'initial',
name: 'common',
enforce: true,
},
components: {
test: /components/,
chunks: 'initial',
name: 'components',
enforce: true,
},
},
},
},
};
if (NODE_ENV === 'production') {
result.plugins.push(
new SentryCliPlugin({
release: gitRevisionPlugin.version(),
include: './static/js/',
ignore: ['node_modules', 'webpack.config.js']
}))
}
return result;
};