forked from gnosis/dx-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.config.js
184 lines (176 loc) · 4.62 KB
/
webpack.dev.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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-enable import/no-extraneous-dependencies */
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const path = require('path')
const webpack = require('webpack')
const pkg = require('./package.json')
const nodeEnv = process.env.NODE_ENV || 'development'
const version = process.env.BUILD_VERSION || pkg.version
const build = process.env.BUILD_NUMBER || 'SNAPSHOT'
const config = require('./src/config.json')
const whitelist = config.developmentWhitelist
const ethereumUrl = process.env.ETHEREUM_URL || `${config.ethereum.protocol}://${config.ethereum.host}:${config.ethereum.port}`
module.exports = {
context: path.join(__dirname, 'src'),
entry: 'index.tsx',
devtool: 'eval-source-map',
output: {
publicPath: '',
path: process.env.CLAIM_ONLY ? `${__dirname}/dist/legacy` : `${__dirname}/dist/dev`,
filename: 'bundle.js',
},
resolve: {
symlinks: false,
modules: [
`${__dirname}/src`,
'node_modules',
],
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
},
{
test: /\.tsx?$/,
exclude: /(node_modules)/,
use: {
loader: 'awesome-typescript-loader',
options: {
useBabel: true,
useCache: true,
babelCore: '@babel/core',
},
},
},
{
test: /\.(jpe?g|png|svg|gif)$/i,
use: {
loader: 'file-loader',
options: {
name: 'img/[name].[ext]',
},
},
},
{
test: /\.(pdf)$/i,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
},
{
test: /\.s?css$/,
use: [
{
loader: 'style-loader',
options: {
sourceMap: true,
},
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: true,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.scss$/,
use: {
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
},
{
test: /\.(ttf|otf|eot|woff2?)(\?[a-z0-9]+)?$/,
use: {
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
},
},
},
{
test: /\/build\/contracts\/\w+\.json$/,
use: ['json-loader', 'json-x-loader?exclude=unlinked_binary+networks.*.events+networks.*.links+bytecode+deployedBytecode+sourceMap+deployedSourceMap+source+sourcePath+ast+legacyAST']
},
],
},
devServer: {
disableHostCheck: true,
historyApiFallback: true,
port: 5000,
host: '0.0.0.0',
clientLogLevel: 'info',
hot: true,
watchOptions: {
ignored: /node_modules/,
},
},
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new FaviconsWebpackPlugin({
logo: 'assets/favicon.png',
prefix: './',
// Generate a cache file with control hashes and
// don't rebuild the favicons until those hashes change
persistentCache: true,
icons: {
android: false,
appleIcon: false,
appleStartup: false,
coast: false,
favicons: true,
firefox: false,
opengraph: false,
twitter: false,
yandex: false,
windows: false,
},
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/html/index.html'),
}),
new webpack.DefinePlugin({
'process.env': {
ETHEREUM_URL: JSON.stringify(ethereumUrl),
FE_CONDITIONAL_ENV: JSON.stringify(process.env.FE_CONDITIONAL_ENV || 'development'),
USE_DEV_NETWORKS: JSON.stringify(process.env.USE_DEV_NETWORKS),
NODE_ENV: JSON.stringify(nodeEnv),
CLAIM_ONLY: JSON.stringify(process.env.CLAIM_ONLY),
VERSION: JSON.stringify(`${version}#${build}`),
WHITELIST: JSON.stringify(whitelist),
},
}),
new CopyWebpackPlugin([{
from: 'public',
}, {
from: '../landing',
to: 'landing',
}]),
],
}