repos

blog.bythewood.me-wagtail

mirror archived upstream

Self-hostable blog for developers built on Wagtail and Django, with webpack, Bootstrap, and CodeMirror.

blogbootstrapdjangodockerhandcodedpythonself-hostedwagtailwebpack

1.4 KB · 58 lines · JavaScript Raw History
 1const path = require("path");
 2
 3const MiniCssExtractPlugin = require("mini-css-extract-plugin");
 4const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
 5const TerserPlugin = require("terser-webpack-plugin");
 6const BASE_DIR = __dirname;
 7
 8module.exports = {
 9  entry: {
10    "admin.global": "./admin/static_src/global/index.js",
11    "admin.editor": "./admin/static_src/editor/index.js",
12    base: "./blog/static_src/index.js",
13    pages: "./pages/static_src/index.js",
14  },
15  output: {
16    path: path.resolve(BASE_DIR, "blog/static"),
17    filename: "[name].js",
18  },
19  optimization: {
20    minimize: true,
21    minimizer: [
22      new CssMinimizerPlugin(),
23      new TerserPlugin(),
24    ],
25  },
26  plugins: [
27    new MiniCssExtractPlugin({
28      filename: "[name].css",
29    }),
30  ],
31  module: {
32    rules: [
33      // Extract all CSS into their own files
34      {
35        test: /\.css$/,
36        use: [MiniCssExtractPlugin.loader, "css-loader"],
37      },
38      {
39        test: /\.scss$/,
40        use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
41      },
42      // Copy all images to the build directory
43      {
44        test: /\.(png|jpg|gif|svg|webp)$/,
45        use: [
46          {
47            loader: "file-loader",
48            options: {
49              name: "[name].[ext]",
50              outputPath: "images/",
51            },
52          },
53        ],
54      },
55    ],
56  },
57};