This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
83 lines (75 loc) · 1.95 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
/**
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or
* https://opensource.org/licenses/BSD-3-Clause
*/
const path = require('path');
// creates index.html folder and puts it in dist folder
const HtmlWebpackPlugin = require('html-webpack-plugin');
const dotenv = require('dotenv-webpack');
const ZipPlugin = require('zip-webpack-plugin');
const env = require('./config.js').env;
const url = require('./config.js')[env].refocusUrl;
const botName = require('./package.json').name;
const TerserPlugin = require('terser-webpack-plugin');
const config = {
entry: './web/index.js',
output: {
path: path.resolve(__dirname, './web/dist'),
filename: 'index_bundle.js',
publicPath: '/'
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin({})],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: [/(node_modules)/, path.resolve(__dirname, 'web/dist')],
include: [path.resolve(__dirname, 'web')],
loader: 'babel-loader'
},
{
test: /\.css$/,
loader: ['style-loader', 'css-loader']
},
{
test: /.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
loader: 'url-loader?limit=100000',
include: path.resolve(__dirname, 'web'),
},
]
},
node: {
fs: 'empty'
},
devServer: {
historyApiFallback: true
},
plugins: [
new HtmlWebpackPlugin({
template: 'web/index.html',
url: url + '/v1/',
name: botName,
}),
new ZipPlugin({
filename: 'bot.zip',
include: [/\.js$/, /\.html$/],
exclude: ['public']
}),
new dotenv({
path: './.env',
safe: false,
systemvars: true
}),
],
};
// eslint-disable-next-line no-process-env
if (process.env.NODE_ENV !== 'production') {
config.optimization.minimize = false;
}
module.exports = config;