0

I am able to see the source maps when I run the application locally i.e "npm start". Even it points to the exact line of exception.

But when I run "npm run make" and open the myApp.app, it doesn't work. I don't see the line causing the error. It shows log like this .app/Contents/Resources/app/.webpack/main/index.js:8:109084 which is not reflecting the correct line number

import type { Configuration } from 'webpack';
import { rules } from './webpack.rules';

// Define base configuration
const baseConfig: Configuration = {
  devtool: 'source-map',
  plugins: [
  ],
};

export const mainConfig: Configuration = {
    /**
   * This is the main entry point for your application, it's the first file
   * that runs in the main process.
   */
  entry: './src/main/main.js',
  // Put your normal webpack config below here
  module: {
    rules,
  },
  resolve: {
    extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
  },
  externals: process.platform === 'darwin' ? [
    '@myApp/ffi-napi',
    '@myApp/ref-napi',
  ] : [
    '@myApp/electron-edge-js'
  ],
};

const mergedConfig: Configuration = {
  ...baseConfig,
  ...mainConfig,
  plugins: [...(baseConfig.plugins || []), ...(mainConfig.plugins || [])],
};


export default mergedConfig;

package.json:

  "scripts": {
    "start": "electron-forge start",
    "test-win": "nyc --use-spawn-wrap --reporter=cobertura electron-mocha ./test/**/*Test.{js,ts} --require ./test/test_setup.js --timeout 10000 --require ts-node/register",
    "test": "nyc --reporter=cobertura electron-mocha ./test/**/*Test.{js,ts} --require ./test/test_setup.js --timeout 10000 --require ts-node/register",
    "coverage": "./codecov.sh",
    "win-coverage": "codecov.bat",
    "package": "electron-forge package --arch=x64",
    "make": "electron-forge make --arch=x64",
    "build": "npm install --force --loglevel=error && electron-rebuild ",
    "rebuild": "electron-rebuild",
    "installAppDmg": "npm install --force --loglevel=error [email protected]",
    "postinstall": "npmpd",
    "playwright": "NODE_ENV=prod ENV=prod npx playwright test --workers 1",
    "lint": "eslint 'src/main/**/*.ts'"
  },
  "devDependencies": {
    "@electron-forge/cli": "^6.1.1",
    "@electron-forge/maker-deb": "^6.1.1",
    "@electron-forge/maker-rpm": "^6.1.1",
    "@electron-forge/maker-squirrel": "^6.1.1",
    "@electron-forge/maker-zip": "^6.1.1",
    "@electron-forge/plugin-auto-unpack-natives": "^6.4.2",
    "@electron-forge/plugin-webpack": "^6.1.1",
    "@playwright/test": "^1.37.0",
    "@types/chai": "^5.0.0",
    "@types/debug": "^4.1.12",
    "@types/draggabilly": "^2.1.4",
    "@types/fs-extra": "^11.0.4",
    "@types/lodash.isequal": "^4.5.7",
    "@types/mocha": "^10.0.9",
    "@types/node": "^20.12.13",
    "@types/react": "^18.2.12",
    "@types/react-dom": "^18.2.5",
    "@types/sinon": "^17.0.3",
    "@types/webpack-node-externals": "^3.0.2",
    "@typescript-eslint/eslint-plugin": "^5.62.0",
    "@typescript-eslint/parser": "^5.62.0",
    "@vercel/webpack-asset-relocator-loader": "1.7.3",
    "chai": "^4.5.0",
    "copy-webpack-plugin": "^11.0.0",
    "cross-env": "^7.0.3",
    "css-loader": "^6.8.1",
    "draggabilly": "^3.0.0",
    "electron": "20.0.0",
    "eslint": "^8.57.1",
    "fork-ts-checker-webpack-plugin": "^7.3.0",
    "mocha": "^10.7.3",
    "node-fetch": "^2.6.6",
    "node-loader": "^2.0.0",
    "npm-platform-dependencies": "^0.1.0",
    "nyc": "^15.1.0",
    "rewire": "^6.0.0",
    "sass-loader": "^13.3.2",
    "sinon": "^11.1.2",
    "spectron": "^14.0.0",
    "style-loader": "^3.3.3",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.5",
    "webpack-node-externals": "^3.0.0"
  },
3
  • 1
    That's probably expected. In most build systems I know, it's the default configuration to create source maps in a development build and not in a production build. What is npm make? Do you mean npm run make? Commented Nov 24, 2024 at 23:58
  • yes, i meant npm run make. How can i generate source maps for prod? Commented Nov 25, 2024 at 6:12
  • If I correctly understand this website webpack.js.org/guides/production, you can't. Commented Nov 25, 2024 at 7:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.