const webpack = require('webpack') const { merge } = require('webpack-merge') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin') process.env.REACT_REFRESH = '1' const base = require('./webpack.config') // if WEBPACK_ENTRYPOINTS is defined, remove any entrypoints that aren't included if (process.env.WEBPACK_ENTRYPOINTS) { const entrypoints = new Set(process.env.WEBPACK_ENTRYPOINTS.split(/\s*,\s*/)) console.log(`Building entrypoints ${[...entrypoints].join(',')}`) for (const entrypoint in base.entry) { if (!entrypoints.has(entrypoint)) { delete base.entry[entrypoint] } } } module.exports = merge(base, { mode: 'development', // Enable accurate source maps for dev devtool: process.env.CSP_ENABLED === 'true' ? 'source-map' : 'eval-source-map', // Load entrypoints without contenthash in filename output: { filename: 'js/[name].js', }, // Load assets without contenthash in filename module: { rules: [ { test: /\.(woff|woff2)$/, type: 'asset/resource', generator: { filename: 'fonts/[name][ext]', }, }, { test: /\.(svg|gif|png|jpg|pdf)$/, type: 'asset/resource', generator: { filename: 'images/[name][ext]', }, }, ], }, plugins: [ // Extract CSS to a separate file (rather than inlining to a