This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
74 lines (73 loc) · 2.33 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
const path = require("path");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const RemovePlugin = require('remove-files-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
module.exports = {
devtool: 'source-map',
entry: {
cookieBanner: './core/js/src/dit.cookieBanner.js',
reveal: './core/js/src/dit.reveal.js',
tagging: './core/js/src/dit.tagging.js',
videoHeroControl: './core/js/src/dit.videoHeroControl.js',
main_styles: './core/sass/main.scss',
atlas_styles: './core/sass/atlas/main.scss',
atlas_header_footer_styles: './core/sass/atlas/header-footer.scss'
},
output: {
path: path.resolve(__dirname, 'core', 'static', 'core'),
filename: 'js/dit.[name]-min.js',
},
module: {
rules: [
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
// URLs in source are relative to compiled CSS, /static/core/styles/main.css
url: false
}
},
'sass-loader'
]
},
],
},
optimization: {
minimize: true,
minimizer: [
"...",
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.sharpMinify,
},
}),
],
},
plugins: [
new MiniCssExtractPlugin({
filename: ({chunk: {name}}) => `styles/${name.replace('_styles', '')}.css`,
}),
new CopyWebpackPlugin({
patterns: [
{
from: './core/assets/',
noErrorOnMissing: true,
},
]
}),
new RemovePlugin({
after: {
test: [
{
folder: './core/static/core/js',
method: (absoluteItemPath) => new RegExp(/_styles-min\.js(\.map)?$/).test(absoluteItemPath)
},
],
},
}),
]
}