generated from app-generator/app-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
82 lines (80 loc) · 2.46 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
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const { SourceMapDevToolPlugin } = require("webpack");
const path = require('path');
const BundleTracker = require("webpack-bundle-tracker");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = [
{
entry: './static/assets/index.js', // path to your input file
output: {
filename: '[name].bundle.js', // output bundle file name
path: path.resolve(__dirname, './static/dist'), // path to your Django static directory
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
outputPath: 'static/images/'
}
},
{
test: /\.(ttf|eot|svg|gif|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: [{
loader: 'file-loader',
}]
},
],
},
resolve: {
extensions: ['', '.js', '.jsx', '.css']
},
plugins: [
new MiniCssExtractPlugin(),
new SourceMapDevToolPlugin({
filename: "[file].map"
}),
],
optimization: {
minimizer: [
new CssMinimizerPlugin()
]
},
},
{
entry: {
frontend: "./frontend/src/index.js",
},
output: {
path: path.resolve("./frontend/static/frontend/"),
filename: "[name]-[fullhash].js",
publicPath: "/static/frontend/",
},
plugins: [
new CleanWebpackPlugin(),
new BundleTracker({
path: __dirname,
filename: "./webpack-stats.json",
}),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
],
},
},
];