forked from sixem/ivfi-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·97 lines (82 loc) · 1.98 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
const package = require('./package.json');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const webpack = require('webpack');
const moment = require('moment');
const banner = () =>
{
return `
@preserved
## eyy-indexer - ${package.description} ##
[Version: ${package.version}]
[Git: https://github.com/sixem/eyy-indexer]
[Build: [fullhash] @ ${moment().format('dddd, MMMM Do YYYY')}]
[Chunkhash: [chunkhash]]
Copyright (c) 2021 emy | five.sh | github.com/sixem
Licensed under GPL-3.0
\n`;
};
module.exports = (env) => {
return {
context: __dirname,
mode: env.production ? 'production' : 'development',
entry: {
index: './src/js/main.js'
},
output: {
filename: 'main.js',
path: __dirname + '/build/indexer/js'
},
optimization: {
minimize: env.production ? true : false,
minimizer: [
new TerserPlugin({
extractComments: false
}),
new CssMinimizerPlugin()
]
},
plugins: [
new HtmlWebpackPlugin({
inject: false,
minify: false,
template: __dirname + '/src/php/index.php',
filename: __dirname + '/build/indexer.php',
templateParameters: (compilation) => {
return {
version: package.version,
indexerPath : '/indexer/'
}
}
}),
new MiniCssExtractPlugin({
filename: '../css/style.css'
}),
new webpack.BannerPlugin({
banner: banner(),
entryOnly: true
}),
],
module: {
rules: [
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.(woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [
{
loader: 'file-loader',
options: {
name: '../assets/fonts/[name].[ext]'
}
}
]
}
]
}
}
};