forked from ilfrich/flask-react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (51 loc) · 1.58 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
const webpack = require("webpack")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const path = require("path")
const BUILD_DIR = path.resolve(__dirname, "static")
const APP_DIR = path.resolve(__dirname, "frontend", "src")
const HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: "frontend/index.html",
filename: "../templates/index.html",
inject: true,
})
// Enable multi-pass compilation for enhanced performance
// in larger projects. Good default
const HotModuleReplacementPluginConfig = new webpack.HotModuleReplacementPlugin({
multiStep: false,
})
// See https://medium.com/@kimberleycook/intro-to-webpack-1d035a47028d#.8zivonmtp for
// a step-by-step introduction to reading a webpack config
const config = {
entry: `${APP_DIR}/index.js`,
output: {
path: BUILD_DIR,
filename: "index.js",
publicPath: "/static",
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|jpg|jpeg)$/,
use: [
{
loader: "url-loader",
options: {
limit: 65536,
},
},
],
},
],
},
plugins: [HTMLWebpackPluginConfig, HotModuleReplacementPluginConfig],
}
module.exports = config