-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
92 lines (89 loc) · 2.37 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
83
84
85
86
87
88
89
90
91
92
const path = require('path');
const { DefinePlugin } = require('webpack');
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const SentryCliPlugin = require('@sentry/webpack-plugin');
const MODE = process.env.WEBPACK_MODE || 'production';
const PRODUCTION = MODE === 'production';
const DEVTOOL = PRODUCTION ? 'source-map' : 'eval';
const { SENTRY_AUTH_TOKEN } = process.env;
module.exports = {
mode: MODE,
devtool: DEVTOOL,
entry: {
main: [
'./web/entry/sentry',
'./web/entry/main',
]
},
output: {
filename: 'subtractor.js',
path: path.resolve(__dirname, 'build', 'static'),
publicPath: '/static/',
},
resolve: {
alias: {
'root': path.resolve(__dirname),
'core': path.resolve(__dirname, 'core'),
'presets': path.resolve(__dirname, 'presets'),
'images': path.resolve(__dirname, 'web', 'images'),
'style': path.resolve(__dirname, 'web', 'style'),
'ui': path.resolve(__dirname, 'web', 'ui'),
'vue$': 'vue/dist/vue.esm.js'
}
},
plugins: [
new DefinePlugin({
'SENTRY_ENABLED': JSON.stringify(PRODUCTION),
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'web', 'html', 'index.html'),
filename: '../index.html',
inject: 'body',
alwaysWriteToDisk: true,
}),
new HtmlWebpackHarddiskPlugin(),
new ExtractCssChunks(),
PRODUCTION &&
SENTRY_AUTH_TOKEN &&
new SentryCliPlugin({
include: '.',
ignore: ['node_modules', 'webpack.config.js'],
})
].filter(o => o),
devServer: {
host: '0.0.0.0',
port: 7200,
historyApiFallback: true,
disableHostCheck: true,
index: path.join(__dirname, 'build', 'index.html'),
contentBase: path.join(__dirname, 'build'),
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif|json|ico)$/,
include: [path.resolve(__dirname, 'web', 'images')],
use: [
{
loader: 'file-loader',
},
],
},
{
test: /\.js$/,
exclude: [/node_modules/,],
loader: 'babel-loader'
},
{
test: /\.scss$/,
use: [
ExtractCssChunks.loader,
'css-loader',
'sass-loader',
]
},
]
},
};