-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.ui.config.js
161 lines (155 loc) · 4 KB
/
webpack.ui.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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const { compilerOptions } = require('./tsconfig.json');
const isProd = process.env.NODE_ENV === 'production';
const devServerEntries = [
// 'webpack-dev-server/client?http://localhost:8080',
// 'webpack/hot/only-dev-server',
];
const envPlugin = new webpack.EnvironmentPlugin({
NODE_ENV: '',
BASE_URL: '',
WEB3_HTTP_PROVIDER: '',
ENS_RESOLVER: '',
INDEXER_API: '',
ARB_HTTP_PROVIDER: '',
ARB_REGISTRAR: '',
ARB_EXPLORER: '',
GUN_PEERS: [],
APP_TITLE: 'Zkitter',
APP_LOGO: '',
WC_PROJECT_ID: '',
});
const rules = [
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.tsx?$/,
exclude: /(node_modules|.webpack)/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
];
const rendererRules = [
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
publicPath: 'assets',
bypassOnDebug: true, // [email protected]
disable: true, // [email protected] and newer
},
},
],
},
{
test: /\.(s[ac]ss|css)$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
];
module.exports = [
{
target: 'web',
mode: isProd ? 'production' : 'development',
entry: {
app: path.join(__dirname, 'src', 'app.tsx'),
serviceWorker: path.join(__dirname, 'src', 'serviceWorkers', 'index.ts'),
},
output: {
path: __dirname + '/build',
publicPath: isProd ? '/' : 'http://localhost:8080/',
filename: `[name].js`,
},
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.png', '.svg'],
modules: [path.resolve('./node_modules'), path.resolve(__dirname, compilerOptions.baseUrl)],
alias: {
'@components': 'src/components',
'@ducks': 'src/ducks',
'~': 'src/util',
'#': 'static',
},
fallback: {
browserify: require.resolve('browserify'),
stream: require.resolve('stream-browserify'),
path: require.resolve('path-browserify'),
crypto: require.resolve('crypto-browserify'),
os: require.resolve('os-browserify/browser'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
assert: require.resolve('assert/'),
constants: false,
fs: false,
},
},
module: {
rules: [...rules, ...rendererRules],
},
plugins: [
envPlugin,
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process',
}),
new CopyPlugin({
patterns: [
{
from: process.env.FAVICON || __dirname + '/static/icons/favicon.zkitter.png',
to: __dirname + '/build/favicon.png',
},
{
from: process.env.MANIFEST || __dirname + '/static/manifest.zkitter.json',
to: __dirname + '/build/manifest.json',
},
{
from: process.env.APP_LOGO || __dirname + '/static/icons/zkitter_logo.svg',
to: __dirname + '/build/applogo.svg',
},
],
}),
new HtmlWebpackPlugin({
template: './static/index.template.ejs',
filename: `index.html`,
title: process.env.APP_TITLE || 'Zkitter',
inject: true,
}),
new webpack.ContextReplacementPlugin(/gun/),
],
stats: 'minimal',
devServer: {
historyApiFallback: true,
proxy: {
'/rest': {
target: `http://127.0.0.1:8080`,
secure: true,
},
},
},
// optimization: {
// runtimeChunk: 'single'
// },
},
];