-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
95 lines (91 loc) · 2.83 KB
/
webpack.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
'use strict';
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const rendererOptimization = {
splitChunks: {
cacheGroups: {
vendors: {
test: mod => {
return /[\\/]node_modules[\\/]/.test(mod.context);
},
chunks: 'initial',
name: 'vendors',
priority: 10,
enforce: true
}
}
},
minimizer: [
// We won't minimize for now
]
};
// const extractAppCssPlugin = new MiniCssExtractPlugin({
// filename: '[name].min.css'
// });
module.exports = {
mode: 'development',
entry: {
app: ['./src/client/Index.tsx'/*, 'webpack-hot-middleware/client'*/]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[hash].js'
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
modules: [path.resolve('.'), 'node_modules']
},
module: {
rules: [
// {
// enforce: 'pre',
// test: /\.js$/,
// loader: 'source-map-loader',
// exclude: path.resolve(__dirname, 'node_modules')
// },
// {
// test: /\.jsx$/,
// loader: 'babel-loader',
// exclude: path.resolve(__dirname, 'node_modules')
// },
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
exclude: path.resolve(__dirname, 'node_modules')
},
{
test: /\.mdx?$/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/env', '@babel/react']
}
},
'@mdx-js/loader'
],
exclude: path.resolve(__dirname, 'node_modules')
},
// { test: /\.(woff|woff2|eot|ttf)$/, loader: 'url-loader', options: { limit: 512 } },
{
test: /\.(jpg|png|svg)$/,
loader: 'url-loader',
options: {
limit: 512,
outputPath: 'assets',
name: '[name].[ext]'
}
},
// { test: /\.ico$/, loader: 'file-loader?name=[name].[ext]' }
]
},
plugins: [
// extractAppCssPlugin,
new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'src', 'client', 'index.html') }),
new webpack.HotModuleReplacementPlugin()
],
optimization: rendererOptimization
};