forked from Balmy-protocol/dca-fe
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
118 lines (116 loc) · 3.6 KB
/
webpack.common.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 HtmlWebpackPlugin = require('html-webpack-plugin');
const tsTransformer = require('@formatjs/ts-transformer');
const webpack = require('webpack');
const createStyledComponentsTransformer = require('typescript-plugin-styled-components').default;
const WebpackBar = require('webpackbar');
const { mean } = require('lodash');
const styledComponentsTransformer = createStyledComponentsTransformer();
module.exports = {
entry: {
app: './src/index.tsx',
},
plugins: [
new HtmlWebpackPlugin({
title: 'Production',
template: './public/index.html',
favicon: './public/favicon.ico',
inject: false,
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser.js',
}),
new webpack.DefinePlugin({
'process.env.ETHPLORER_KEY': JSON.stringify('EK-7xNxe-HDazjQ3-smGdU'),
}),
new webpack.DefinePlugin({
'process.env.ETHERSCAN_API': JSON.stringify('4UTUC6B8A4X6Z3S1PVVUUXFX6IVTFNQEUF'),
}),
new WebpackBar(),
],
devtool: 'source-map',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
resolve: {
alias: {
'@common': path.resolve(__dirname, 'src/common'),
'@assets': path.resolve(__dirname, 'src/assets'),
'@abis': path.resolve(__dirname, 'src/abis'),
'@fonts': path.resolve(__dirname, 'src/fonts'),
'@constants': path.resolve(__dirname, 'src/constants'),
'@frame': path.resolve(__dirname, 'src/frame'),
'@graphql': path.resolve(__dirname, 'src/graphql'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@lang': path.resolve(__dirname, 'src/lang'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@services': path.resolve(__dirname, 'src/services'),
'@state': path.resolve(__dirname, 'src/state'),
'@types': path.resolve(__dirname, 'src/types'),
},
extensions: ['*', '.js', '.jsx', '.ts', '.tsx'],
fallback: {
stream: require.resolve('stream-browserify'),
crypto: require.resolve('crypto-browserify'),
assert: require.resolve('assert/'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
url: require.resolve('url'),
},
},
module: {
rules: [
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: { presets: ['@babel/env'] },
},
{
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
// Limit at 50k. Above that it emits separate files
limit: 50000,
// url-loader sets mimetype if it's passed.
// Without this it derives it from the file extension
mimetype: 'application/font-woff',
// Output below fonts directory
name: 'fonts/[name].[ext]',
},
},
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
allowTsInNodeModules: true,
getCustomTransformers() {
return {
before: [
tsTransformer.transform({
overrideIdFn: '[sha512:contenthash:base64:6]',
}),
styledComponentsTransformer,
],
};
},
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
};