-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (96 loc) · 2.41 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
const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const SitemapPlugin = require('sitemap-webpack-plugin').default;
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require('webpack');
const pjson = require('./package.json');
var today = () => {
let d = new Date();
let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);
let mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(d);
let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);
return `${ye}-${mo}-${da}`;
}
const paths = [
{
path: '/',
lastmod: true,
priority: 1,
changefreq: 'monthly'
}
]
module.exports = {
entry: [
path.resolve(__dirname, './src/index.js'),
],
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js',
},
// devServer: {
// contentBase: path.resolve(__dirname, './dist'),
// },
plugins: [
new CopyPlugin({
patterns: [
{
from: "./src",
globOptions: {
ignore: [
'**/*.scss',
'**/*.sass',
'**/index.js'
]
}
},
],
options: { concurrency: 100 },
}),
new WebpackManifestPlugin({
basePath: "",
publicPath: "/"
}),
new BrowserSyncPlugin({
host: 'localhost',
port: 4200,
server: { baseDir: ['dist'] }
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pjson.version),
BUILT: JSON.stringify(today())
})
],
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
{
test: /\.html$/i,
type: "asset/resource",
},
],
},
optimization: {
minimize: true,
minimizer: [
// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
// `...`
new TerserPlugin(),
new HtmlMinimizerPlugin({
parallel: true,
}),
],
},
};