forked from deriv-com/binary-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cli.js
118 lines (117 loc) · 4.33 KB
/
webpack.config.cli.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const path = require('path');
const webpack = require('webpack');
const Dotenv = require('dotenv-webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const BlocklyConcatPlugin = require('./plugins/blockly-concat-plugin');
const BlocklyTranslationsPlugin = require('./plugins/blockly-translation-plugin');
module.exports = {
mode: 'production',
entry: path.join(__dirname, 'src/index.js'),
output: {
path: path.resolve(__dirname, 'www'),
filename: 'index.js',
},
target: 'web',
module: {
rules: [
{
test: /\.(js|jsx|cjs|mjs)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', { targets: 'defaults' }]],
},
},
},
{
test: /\.(css|scss|sass)$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
plugins: [
new CleanWebpackPlugin(['www']),
new Dotenv(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.TRACKJS_TOKEN': JSON.stringify(process.env.TRACKJS_TOKEN),
'process.env.GD_APP_ID': JSON.stringify(process.env.GD_APP_ID),
'process.env.GD_CLIENT_ID': JSON.stringify(process.env.GD_CLIENT_ID),
'process.env.GD_API_KEY': JSON.stringify(process.env.GD_API_KEY),
}),
new BlocklyConcatPlugin({
outputPath: '/',
fileName: 'blockly.js',
filesToConcat: [
'./node_modules/blockly/blockly_compressed.js',
'./node_modules/blockly/blocks_compressed.js',
'./node_modules/blockly/javascript_compressed.js',
'./node_modules/blockly/msg/messages.js',
],
}),
new BlocklyTranslationsPlugin({
outputPath: path.resolve(__dirname, 'www/blockly-translations'),
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
}),
new webpack.BannerPlugin({
banner: '#!/usr/bin/env node',
raw: true,
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'node_modules/@deriv/deriv-charts/dist/',
to: path.resolve(__dirname, 'www/js'),
},
{
from: 'public',
to: path.resolve(__dirname, 'www/public'),
globOptions: {
ignore: ['**/*.html'],
},
},
{
from: 'public/index.html',
to: path.resolve(__dirname, 'www/index.html'),
toType: 'file',
},
{
from: 'public/beta.html',
to: path.resolve(__dirname, 'www/beta.html'),
toType: 'file',
},
{
from: 'public/localstorage-sync.html',
to: path.resolve(__dirname, 'www/localstorage-sync.html'),
toType: 'file',
},
],
}),
],
resolve: {
extensions: ['.js', '.jsx'],
alias: {
'@lang': path.resolve(__dirname, 'src/common/lang'),
'@config': path.resolve(__dirname, 'src/config'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@storage': path.resolve(__dirname, 'src/storage'),
'@constants': path.resolve(__dirname, 'src/constants'),
'@i18n': path.resolve(__dirname, 'src/i18n'),
'@api-base': path.resolve(__dirname, 'src/api-base'),
'@components': path.resolve(__dirname, 'src/components'),
'@redux-store': path.resolve(__dirname, 'src/redux-store'),
'@blockly': path.resolve(__dirname, 'src/blockly'),
'@utilities': path.resolve(__dirname, 'src/utilities'),
'@currency-config': path.resolve(__dirname, 'src/currency-config'),
},
},
optimization: {
minimize: true,
},
};