-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
59 lines (57 loc) · 1.65 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
const env = require("dotenv").config().parsed;
const path = require("path");
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const envKeys = Object.keys(env).reduce((prev, next) => {
prev[`process.env.${next}`] = JSON.stringify(env[next]);
return prev;
}, {});
module.exports = {
entry: "./src/main.js",
output: {
path: path.join(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/",
},
devServer: {
port: process.env.NODE_PORT,
historyApiFallback: true, // Reloads the app on last visited route (important)
open: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader",
},
{
test: /\.css$/,
loader: "style-loader!css-loader",
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: "file-loader",
options: {
outputPath: "assets/images/",
},
},
{
test: /\.(eot|woff|ttf|otf)$/,
loader: "file-loader",
options: {
outputPath: "assets/fonts/",
},
},
],
},
plugins: [
new CleanWebpackPlugin(["dist"]),
new HtmlWebPackPlugin({
template: "./src/index.html",
favicon: "./src/assets/images/icon.png",
}),
new webpack.DefinePlugin(envKeys),
],
};