-
Notifications
You must be signed in to change notification settings - Fork 17
/
webpack.common.js
111 lines (108 loc) · 2.74 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
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
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
module.exports = {
target: "web",
context: __dirname,
entry: {
home: ["/src/js/index.js", "/src/sass/home.sass"],
},
output: {
path: path.resolve(__dirname, "build"),
filename: "[chunkhash].js",
chunkFilename: "[id].bundle.js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
include: [path.resolve(__dirname, "js", "src")],
exclude: [path.resolve(__dirname, "node_modules")],
use: {
loader: "esbuild-loader",
}
},
{
test: /\.(css|sass|scss)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
// modules: true,
// importLoaders allows to configure how many loaders before css-loader should be applied to @imported resources.
// 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader
importLoaders: 2,
}
},
{
loader: "sass-loader",
}
]
},
// rule for textures (images)
{
test: /\.(jpe?g|png|tif)$/i,
include: path.resolve(__dirname, "src", "textures"),
use: [
"file-loader",
{
loader: "image-webpack-loader",
options: {
disable: true, // [email protected] and newer
mozjpeg: {
progressive: true,
},
optipng: {
optimizationLevel: 7,
},
gifsicle: {
interlaced: false,
},
pngquant: {
quality: [0.65, 0.90],
speed: 4
},
}
}
]
}
]
},
devServer: {
host: "localhost",
port: 8080,
open: true,
hot: true,
historyApiFallback: true,
client: {
overlay: {
errors: true,
warnings: false
}
}
},
plugins: [
// new BundleAnalyzerPlugin(),
new CleanWebpackPlugin({
root: __dirname,
exclude: ["favicon.ico"],
verbose: true
}),
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
chunkFilename: '[id].[hash].css',
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src", "templates", "index.html"),
hash: true,
filename: "index.html",
chunks: ["commons", "home"]
}),
],
externals: {
GeoTIFF: 'GeoTIFF',
},
};