-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
72 lines (70 loc) · 2 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyPlugin = require("copy-webpack-plugin");
let commitHash = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString();
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
}),
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(require('./package.json').version),
__COMMIT_HASH__: JSON.stringify(commitHash),
}),
new MiniCssExtractPlugin(),
new CopyPlugin({
patterns: [
{from: "src/robots.txt", to: "robots.txt"},
]
}),
],
module: {
rules: [
{
test: /\.s?[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader",
]
},
{
test: /\.(png|jpe?g|svg|gif)$/,
type: 'asset/resource',
generator: {
filename: 'img/[hash][ext][query]',
},
},
{
test: /\.(eot|woff|woff2|ttf)$/,
use: ['file-loader']
},
{
test: /\.html$/,
use: ['html-loader']
},
{
test: /\.gpx$/,
use: ['gpx-loader']
}
]
},
resolveLoader: {
modules: ['node_modules', path.resolve(__dirname, 'loaders')]
},
};