From 0e1c90afeb7c6d1eb4cf0491a447909e46e67f01 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <cwillisf@media.mit.edu> Date: Tue, 11 Aug 2020 19:14:39 -0700 Subject: [PATCH] write configs to files in dist/ for debugging purposes --- package.json | 4 ++-- webpack.makeConfig.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8c42063..82f80b3 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "license": "BSD-3-Clause", "scripts": { "clean": "rimraf ./dist ./static/assets", - "start": "electron-webpack dev --bail --display-error-details --env.minify=false", - "compile": "electron-webpack --bail --display-error-details --env.minify=false", + "start": "mkdirp ./dist && electron-webpack dev --bail --display-error-details --env.minify=false", + "compile": "mkdirp ./dist && electron-webpack --bail --display-error-details --env.minify=false", "fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js", "build": "npm run build:dev", "build:dev": "npm run compile && npm run doBuild -- --mode=dev", diff --git a/webpack.makeConfig.js b/webpack.makeConfig.js index 57b37e6..d3403b6 100644 --- a/webpack.makeConfig.js +++ b/webpack.makeConfig.js @@ -1,5 +1,7 @@ const childProcess = require('child_process'); +const fs = require('fs'); const path = require('path'); +const util = require('util'); const electronPath = require('electron'); const webpack = require('webpack'); @@ -56,7 +58,7 @@ const makeConfig = function (defaultConfig, options) { }); } - return merge.smart(defaultConfig, { + const config = merge.smart(defaultConfig, { devtool: 'cheap-module-eval-source-map', mode: isProduction ? 'production' : 'development', module: { @@ -117,6 +119,13 @@ const makeConfig = function (defaultConfig, options) { } } }); + + fs.writeFileSync( + `dist/webpack.${options.name}.js`, + `module.exports = ${util.inspect(config, {depth: null})};\n` + ); + + return config; }; module.exports = makeConfig;