webpack.main.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2017-2020 @polkadot/apps authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. /* eslint-disable camelcase */
  5. const TerserPlugin = require('terser-webpack-plugin');
  6. const path = require('path');
  7. const ENV = process.env.NODE_ENV || 'production';
  8. const isProd = ENV === 'production';
  9. function createWebpack () {
  10. return [
  11. {
  12. entry: {
  13. electron: './src/electron',
  14. preload: './src/preload.ts'
  15. },
  16. mode: ENV,
  17. module: {
  18. rules: [
  19. {
  20. exclude: /(node_modules)/,
  21. test: /\.(js|ts|tsx)$/,
  22. use: [
  23. require.resolve('thread-loader'),
  24. {
  25. loader: require.resolve('babel-loader'),
  26. options: require('@polkadot/dev/config/babel')
  27. }
  28. ]
  29. }
  30. ]
  31. },
  32. node: {
  33. __dirname: false
  34. },
  35. optimization: {
  36. minimize: !!isProd,
  37. minimizer: [new TerserPlugin()]
  38. },
  39. output: {
  40. filename: '[name].js',
  41. path: path.join(__dirname, '/build')
  42. },
  43. resolve: {
  44. extensions: ['.js', '.jsx', '.json', '.ts', '.tsx']
  45. },
  46. target: 'electron-main'
  47. }
  48. ];
  49. }
  50. module.exports = createWebpack();