-
Notifications
You must be signed in to change notification settings - Fork 13
/
webpack.config.js
64 lines (61 loc) · 1.94 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
const webpack = require("webpack");
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
entry: "./static-src/index.js",
output: {
path: path.resolve(__dirname, "./ethicalads-theme/static/dist"),
filename: "bundle.js",
},
module: {
rules: [
{
// https://webpack.js.org/guides/asset-management/#loading-fonts
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
{
test: /\.s?css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: (resourcePath, context) => {
// publicPath is the relative path of the resource to the context
// e.g. for ./css/admin/main.css the publicPath will be ../../
// while for ./css/main.css the publicPath will be ../
// https://webpack.js.org/plugins/mini-css-extract-plugin/#the-publicpath-option-as-function
return path.relative(path.dirname(resourcePath), context) + "/theme/dist/";
},
},
},
"css-loader",
"sass-loader",
],
},
],
},
optimization: {
minimizer: [new TerserPlugin(), new CssMinimizerPlugin()],
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
filename: "[name].css",
chunkFilename: "[id].css",
}),
// Makes jQuery (required for bootstrap4) available to other JS includes
// https://webpack.js.org/plugins/provide-plugin/
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
}),
],
};