-
Notifications
You must be signed in to change notification settings - Fork 148
/
webpack.config.js
111 lines (109 loc) · 2.91 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const DynamicCdnWebpackPlugin = require('dynamic-cdn-webpack-plugin');
module.exports = {
mode: 'development',
entry: ['./app/index'],
output: {
path: path.join(__dirname),
filename: 'bundle.js',
},
resolve: {
modules: ['node_modules'],
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
module: {
rules: [
{
test: /\.(j|t)s(x)?$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
// eslint options (if necessary)
},
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [
process.env.NODE_ENV !== 'production'
? 'style-loader'
: MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
use: { loader: 'url-loader?limit=100000', },
},
{
test: /\.(j|t)s(x)?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
presets: [
[
'@babel/preset-env',
{
targets: { browsers: 'last 2 versions' },
useBuiltIns: 'entry',
corejs: '3',
},
],
'@babel/preset-typescript',
'@babel/react',
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
['babel-plugin-typescript-to-proptypes', {}],
],
},
},
},
],
},
devtool: 'eval-source-map',
plugins: [
new ForkTsCheckerWebpackPlugin(),
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'static', 'index.html'),
filename: 'index.html',
}),
//new CopyPlugin([{ from: 'src/static', to: 'static' }]),
// new MiniCssExtractPlugin({
// // Options similar to the same options in webpackOptions.output
// // both options are optional
// filename: '[name].css',
// chunkFilename: '[id].css',
// }),
new DynamicCdnWebpackPlugin({
exclude: ['file-saver']
})
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "initial",
}
}
}
}
};