-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (64 loc) · 1.57 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
/* eslint-disable */
var path = require("path");
var webpack = require("webpack");
var BundleTracker = require("webpack-bundle-tracker");
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: [
"webpack-dev-server/client?http://localhost:3000",
"webpack/hot/only-dev-server",
"./react-app/src/js/index"
],
devtool: 'inline-cheap-module-source-map',
output: {
path: path.resolve("./react-app/bundles/"),
filename: "[name].js",
publicPath: "http://localhost:3000/static/react-app/bundles/" // Tell django to use this URL to load packages and not use STATIC_URL + bundle_name
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: "babel-loader",
exclude: /node_modules/
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
},
],
},
{
test: /\.(sa|sc|c)ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: true,
},
},
'css-loader',
'postcss-loader',
'sass-loader',
],
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(), // don't reload if there is an error
new BundleTracker({
path: __dirname,
filename: "./webpack-stats.json"
}),
new MiniCssExtractPlugin({
filename: "[name].css"
})
],
resolve: {
modules: ["node_modules"],
extensions: [".js", ".jsx"]
}
};