-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cjs
91 lines (90 loc) · 2.21 KB
/
webpack.config.cjs
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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
mode: 'production',
entry: {
main: './src/index.js',
},
devServer: {
hot: true,
port: 3000,
},
watchOptions: {
ignored: /node_modules/,
},
performance: {
maxEntrypointSize: 1536000,
maxAssetSize: 1536000,
},
plugins: [
new webpack.ids.HashedModuleIdsPlugin(),
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin({
patterns: [{ from: './src/icons/', to: './icons' }],
}),
new HtmlWebpackPlugin({
template: './src/index.html',
inject: true,
title: 'Crypto Checker',
}),
new MiniCssExtractPlugin(),
],
module: {
rules: [
{
test: /\.(s(a|c)ss)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.(png|svg|jpe?g|gif)$/i,
type: 'asset/resource',
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-runtime',
],
cacheDirectory: true,
},
},
},
],
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist'),
clean: true,
assetModuleFilename: 'img/[name]-[hash:3].[ext][query]',
},
optimization: {
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/
)[1];
return `npm.${packageName.replace('@', '')}`;
},
},
},
},
},
};