-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
97 lines (89 loc) · 2.14 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
// webpack looks for this filename by default in out "./*" directory.
// declare global plugins/depedencies
let path = require("path");
let HtmlWebpackPlugin = require("html-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const dotenv = require('dotenv')
const webpack = require('webpack')
// exporting this module for the global rules of webpack
module.exports = {
// set entry
entry: "./src/index.js",
// set output
output: {
publicPath: "/",
path: path.resolve(__dirname, "build"),
filename: "bundle.js",
},
module: {
// resolve our different file types
rules: [
{
// checks the extension
test: /.(js|jsx)$/,
// ignores these folders/directories
exclude: /node_modules/,
// if test passes, webpack uses the loaders specified
use: {
loader: "babel-loader",
},
},
{
test: /\.(jpg|mp3|wav|webp|png|ogg|otf|gif|svg|mp4|mov)$/,
loader: 'file-loader',
options: {
name: '[path][name].[hash].[ext]',
},
},
{
test: /\.(scss)$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
{
loader: "sass-loader",
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.html$/i,
loader: 'html-loader',
},
],
},
// set mode
mode: "production",
// mode: "development",
// setup dev server
devServer: {
host: "localhost",
port: "8080",
historyApiFallback: true,
inline: true,
proxy: { "/api": { target: "http://localhost:3000", secure: false } },
},
// set plugins
plugins: [
new HtmlWebpackPlugin({
template: "src/index.html",
// favicon: '/assets/images/postmark-logo.png'
}), new CompressionPlugin({
test: /\.js(\?.*)?$/i,
})
],
// resolve extensions for imports into future components
resolve: {
extensions: [".js", ".jsx"],
alias: {
'@': path.resolve(__dirname, 'src/'),
}
},
};