-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
80 lines (74 loc) · 2.42 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
const path = require("path");
const BundleTracker = require("webpack-bundle-tracker");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const Dotenv = require('dotenv-webpack');
module.exports = {
context: __dirname,
entry: {
index: "./frontend/index"
},
output: {
path: path.resolve("./assets/bundles/"),
publicPath: "/static/bundles/",
filename: "[name].bundle.js"
},
plugins: [
new BundleTracker({filename: "./webpack-stats.json"}),
new MiniCssExtractPlugin({filename: "[name].bundle.css"}),
new ESLintPlugin(),
new Dotenv({
path: './.env', // Path to .env file (this is the default)
safe: true, // load .env.example (defaults to "false" which does not use dotenv-safe)
})
],
module: {
rules: [
// Allow SVGs to be imported either as an asset (to use in an img src, e.g.)
// or via SVGR as a ready-to-use component.
// See docs: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
{
test: /\.svg$/i,
type: 'asset',
resourceQuery: /url/, // *.svg?url
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: { not: [/url/] }, // exclude react component if *.svg?url
use: ['@svgr/webpack'],
},
// Load fonts
{
test: /\.(woff|woff2|eot|ttf)$/,
use: "url-loader"
},
// eslint-disable-next-line max-len
{
test: /\.(scss|css)$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"]
},
{
test: /\.js|.jsx$/,
exclude: /node_modules/,
use: "babel-loader"
},
{
test: /\.(png|jpe?g|gif)$/i,
use: [{loader: "file-loader"}]
},
{
test: /\.mp4$/,
use: "file-loader?name=videos/[name].[ext]"
},
]
},
resolve: {
extensions: ['.js', '.jsx'],
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()]
}
};