This repository was archived by the owner on May 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
87 lines (86 loc) · 1.92 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
const Dotenv = require('dotenv-webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssoWebpackPlugin = require('csso-webpack-plugin').default;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
module.exports = (env, argv) => ({
entry: './src/index.jsx',
module: {
rules: [
{
test: /\.css$/,
use: [
argv.mode === 'development' ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
],
sideEffects: true,
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {
emitFile: true,
},
},
],
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx', 'css'],
},
output: {
path: `${__dirname}/dist`,
publicPath: '/',
filename: 'bundle.js',
},
devServer: {
contentBase: './dist',
port: 1234,
allowedHosts: [
'local.debug',
],
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
plugins: [
new MiniCssExtractPlugin({
filename: 'styles.css',
}),
new Dotenv({
systemvars: true,
}),
new CssoWebpackPlugin(),
new HtmlWebpackPlugin({
template: 'src/index.html',
hash: true,
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
}),
new CopyWebpackPlugin([
{
from: 'src/assets/*',
to: './',
flatten: true,
},
]),
new webpack.NormalModuleReplacementPlugin(
/iconSvgPaths.js/,
`${__dirname}/src/images/iconSvgPaths.js`,
),
],
});