This repository was archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
113 lines (111 loc) · 3.14 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
const StylelintPlugin = require("stylelint-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const config = {
entry: {
main: [
"./src/css/nucleo-icons.css",
"./src/css/nucleo-svg.css",
"./src/css/material-dashboard.css",
"./src/js/core/popper.min.js",
"./src/js/core/bootstrap.min.js",
"./src/js/plugins/perfect-scrollbar.min.js",
"./src/js/plugins/smooth-scrollbar.min.js",
],
editor: {
import: [
// CSS
'./src/assets/css/style.css',
// SCSS
'./src/assets/scss/style.scss',
// JS
'./src/assets/js/script.js',
]
}
},
output: {
filename: "js/[name].js",
},
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: "",
},
},
"css-loader",
"postcss-loader",
],
},
{
test: /\.(scss|sass)$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"sass-loader",
],
},
{
test: /\.svg/,
type: "asset",
parser: {
dataUrlCondition: {
maxSize: 8192
}
},
use: 'svgo-loader',
generator: {
filename: "assets/img/[name][ext][query]",
}
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/resource",
generator: {
filename: "assets/fonts/[name][ext][query]",
}
},
{
test: /\.(png|jpg|gif)$/i,
type: "asset/resource",
generator: {
filename: "assets/img/[name][ext][query]",
}
},
],
},
externals: {
jquery: 'jQuery',
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6,
},
}),
new CssMinimizerPlugin(),
],
},
plugins: [
new StylelintPlugin({
files: ["./**/*.{scss,sass}"],
fix: true,
}),
new MiniCssExtractPlugin({
filename: "css/[name].css",
}),
],
};
module.exports = (env, { mode }) => {
config.devtool = mode === "development" ? "eval-cheap-module-source-map" : "source-map";
return config;
};