-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.dev.js
233 lines (228 loc) · 6.14 KB
/
client.dev.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
const path = require('path')
const webpack = require('webpack')
const AutoDllPlugin = require('../autodll-webpack-plugin-webpack-4')
const ExtractCssChunks = require('../extract-css-chunks-webpack-plugin')
const StatsPlugin = require('stats-webpack-plugin')
const loadPartialConfig = require('@babel/core').loadPartialConfig
const preset = loadPartialConfig({
presets: [
[
require('@babel/preset-env'),
{ useBuiltIns: false, modules: 'commonjs', debug: true }
],
require('@babel/preset-react'),
require('@babel/preset-flow')
],
plugins: [
require('@babel/plugin-proposal-export-default-from'),
require('@babel/plugin-syntax-dynamic-import'),
require('babel-plugin-universal-import'),
require('@babel/plugin-proposal-class-properties'),
[
require('@babel/plugin-transform-runtime'),
{
helpers: false,
polyfill: false,
regenerator: true
}
]
]
})
preset.options.cacheDirectory = true
preset.options.sourceMap = true
preset.options.passPerPreset = false
preset.options.babelrc = false
module.exports = {
mode: 'development',
name: 'client',
target: 'web',
devtool: 'source-map',
// devtool: "cheap-module-source-map",
entry: {
main: [
'./extract-css-chunks-webpack-plugin/hotModuleReplacement2',
'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=false&quiet=false&noInfo=false',
path.resolve(__dirname, '../src/index.jsx')
]
},
cache: true,
output: {
filename: '[name].js',
chunkFilename: '[name].js',
path: path.resolve(__dirname, '../buildClient'),
publicPath: '/static/'
},
module: {
rules: [
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
},
/* {
test: /\.tsx?$/,
exclude: /node_modules/,
include: [
path.resolve(__dirname, '../server'),
path.resolve(__dirname, '../server/src')
],
use: {
loader: 'awesome-typescript-loader',
options: {
useBabel: true,
babelOptions: {
babelrc: false,
presets: [
[require('@babel/preset-env'), { useBuiltIns: false, modules: 'commonjs', debug: true }]
]
},
babelCore: '@babel/core' // needed for Babel v7
}
}
},*/
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: preset.options
}
},
{
test: /\.css$/,
exclude: /node_modules/,
use: ExtractCssChunks.extract({
use: [
{ loader: 'cache-loader' },
{ loader: 'thread-loader', options: { workers: 4 } },
{
loader: 'css-loader',
options: {
// sourceMap: false,
// sourceMap: true, <--- give output error for a normal import on page
modules: true,
localIdentName: '[name]__[local]--[hash:base64:5]'
}
}
]
})
},
{
test: /\.svg$/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: false,
babelrc: false
}
},
require.resolve('svgr/webpack'),
{
loader: require.resolve('url-loader'),
options: {
limit: 1000,
name: '[path][name].[hash:8].[ext]'
}
}
]
},
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
use: {
loader: require.resolve('url-loader'),
options: {
limit: 10,
name: '[path][name].[hash:8].[ext]'
}
}
}
]
} /* optimization: {
flagIncludedChunks:true,
occurrenceOrder:true,
namedModules:false,
namedChunks:false,
sideEffects:true,
usedExports:true,
//concatenateModules: true,
//mergeDuplicateChunks: true,
runtimeChunk: true,
splitChunks: {
chunks: 'async',
cacheGroups: {
styles: {
name: 'bundles/pages/_app.js.css',
test: /\.(sc|c)ss$/,
chunks: 'all',
reuseExistingChunk: true
},
vendors: {
// priority: 1,
reuseExistingChunk: false,
enforce: false,
test: /(node_modules\/(?!webpack-hot).*\.js)/,
name: 'vendors',
chunks: 'all'
}
}
},
minimize: false
},*/,
resolve: {
extensions: ['.mjs', '.ts', '.tsx', '.js', '.jsx', '.css', '.scss'],
alias: {
'rfx-link': path.resolve(__dirname, '../lib/Link'),
rfx: path.resolve(__dirname, '../lib')
}
},
plugins: [
new StatsPlugin('stats.json'),
/* new webpack.optimize.CommonsChunkPlugin({
names: ['bootstrap'], // needed to put webpack bootstrap code before chunks
filename: '[name].js',
minChunks: Infinity
}),*/
// new webpack.NoEmitOnErrorsPlugin(),
new ExtractCssChunks(),
new AutoDllPlugin({
sourceMap: false,
context: path.join(__dirname, '..'),
filename: '[name].js',
config: { plugins: [] },
inherit: true,
entry: {
vendors: [
'react',
'redux',
'react-dom',
'react-redux',
'react-intl',
'graphql',
'graphql-yoga',
'apollo-link',
'apollo-client',
'apollo-cache',
'apollo-cache-inmemory',
'apollo-boost',
'svgr',
'apollo-link-state',
'apollo-link-ws',
'apollo-link-http',
'apollo-link-http-common',
'apollo-utilities'
// 'rfx',
// "rfx-link"
// path.resolve(__dirname, '../lib')
// 'rfx',
// "rfx-link",
// 'transition-group',
// '@babel/polyfill',
// 'redux-devtools-extension/logOnlyInProduction'
]
}
}),
new webpack.HotModuleReplacementPlugin()
// new WriteFilePlugin(), // used so you can see what chunks are produced in dev
]
}