function createWebpackConfig(env, entries) {
const { development, sourceFilePattern, buildDirs } = config;
const preset = { client: "browser", server: "node" }[env];
const webpackConfig = {
mode: development ? "development" : "production",
devtool: development ? "eval-source-map" : false,
entry: entries[env],
output: {
filename: "[chunkhash].js",
path: resolve(buildDirs[env]),
optimization: {
minimizer: [new TerserJSPlugin(), new OptimizeCSSAssetsPlugin()],
usedExports: true,
splitChunks: {
chunks: "all",
plugins: [
new MiniCssExtractPlugin({
filename: "[contenthash].css",
module: {
rules: [
test: file => file.endsWith(".css"),
use: [
{