-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
117 lines (112 loc) · 3.6 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
112
113
114
115
116
117
/*
* Copyright (c) 2023. MIT license
*/
import path from "path";
// const HtmlWebpackPlugin = require('html-webpack-plugin')
import HtmlWebpackPlugin from "html-webpack-plugin";
// const CopyPlugin = require("copy-webpack-plugin");
import CopyPlugin from "copy-webpack-plugin";
// const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
import ImageMinimizerPlugin from "image-minimizer-webpack-plugin";
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
import MiniCssExtractPlugin from "mini-css-extract-plugin";
// const enviroment = require('./configuration/enviroment.js')
import configEnv from "./configuration/enviroment.js";
// const {CleanWebpackPlugin} = require("clean-webpack-plugin");
const configMain = {
entry: {
app: path.resolve(configEnv.paths.source, 'js', 'app.js')
},
output: {
path: configEnv.paths.output,
clean: true,
},
module: {
rules: [
{
test: /\.ejs$/i,
use: ['html-loader', 'template-ejs-loader'],
},
//js-files loader
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
],
}
}
},
{
test: /\.((c|sa|sc)ss)$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'],
},
{
test: /\.(png|gif|jpe?g|svg|eot|ttf|woff|woff2)$/i,
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: configEnv.limits.images,
},
},
},
]
},
optimization: {
runtimeChunk: {
name: (entrypoint) => `runtimechunk~${entrypoint.name}`,
},
minimizer: [
'...',
new ImageMinimizerPlugin({
generator: [
{
// You can apply generator using `?as=webp`, you can use any name and provide more options
preset: "webp",
implementation: ImageMinimizerPlugin.squooshGenerate,
options: {
encodeOptions: {
// Please specify only one codec here, multiple codecs will not work
webp: {
quality: 90,
},
},
},
},
],
}),
],
},
plugins: [
new HtmlWebpackPlugin({
filename: "index.html",
template: "./src/template.ejs",
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(configEnv.paths.source, 'img', 'content'),
to: path.resolve(configEnv.paths.output, 'img', 'content'),
toType: 'dir',
},
]
}),
],
resolve: {
alias: {
config$: './configs/app-config.js',
},
extensions: ['.js', '.jsx'],
modules: [
'node_modules',
'bower_components',
'shared',
'/shared/vendor/modules',
],
},
target: 'web'
}
export default configMain