-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.common.js
81 lines (75 loc) · 2.19 KB
/
webpack.common.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
const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const htmlPlugin = new HtmlWebPackPlugin({
template: "./public/index.html",
filename: "index.html",
});
const copyPlugin = new CopyPlugin({
patterns: [
{ from: "public/robots.txt", to: "robots.txt" },
{ from: "public/favicon.ico", to: "favicon.ico" },
{ from: "public/manifest.json", to: "manifest.json" },
],
})
const miniCssExtractPlugin = new MiniCssExtractPlugin({
filename: 'css/[name].[contenthash].css',
chunkFilename: 'css/[id].[contenthash].css',
})
const jqueryPlugin = new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
})
const esLintPlugin = new ESLintPlugin();
module.exports = {
entry: {
index: {
import: './src/index.js',
dependOn: 'loader',
},
loader: 'lodash',
},
module: {
rules: [
{
test: /\.(scss|css)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
// use: ["style-loader", "css-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|gif|ico)$/i,
type: 'asset/resource',
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, 'src'),
use: {
loader: "babel-loader"
},
},
]},
plugins: [htmlPlugin, copyPlugin, miniCssExtractPlugin, jqueryPlugin, esLintPlugin],
optimization: {
moduleIds: 'deterministic',
runtimeChunk: 'single',
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
};