webpack.main.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
  4. module.exports = {
  5. name: 'tabby-main',
  6. target: 'electron-main',
  7. entry: {
  8. main: path.resolve(__dirname, 'lib/index.ts'),
  9. },
  10. mode: process.env.TABBY_DEV ? 'development' : 'production',
  11. context: __dirname,
  12. devtool: 'source-map',
  13. output: {
  14. path: path.join(__dirname, 'dist'),
  15. pathinfo: true,
  16. filename: '[name].js',
  17. },
  18. resolve: {
  19. modules: ['lib/', 'node_modules', '../node_modules'].map(x => path.join(__dirname, x)),
  20. extensions: ['.ts', '.js'],
  21. },
  22. module: {
  23. rules: [
  24. {
  25. test: /\.ts$/,
  26. use: {
  27. loader: 'ts-loader',
  28. options: {
  29. configFile: path.resolve(__dirname, 'tsconfig.main.json'),
  30. },
  31. },
  32. },
  33. ],
  34. },
  35. externals: {
  36. 'any-promise': 'commonjs any-promise',
  37. electron: 'commonjs electron',
  38. 'electron-config': 'commonjs electron-config',
  39. 'electron-debug': 'commonjs electron-debug',
  40. 'electron-promise-ipc': 'commonjs electron-promise-ipc',
  41. fs: 'commonjs fs',
  42. glasstron: 'commonjs glasstron',
  43. mz: 'commonjs mz',
  44. npm: 'commonjs npm',
  45. 'node-pty': 'commonjs node-pty',
  46. path: 'commonjs path',
  47. util: 'commonjs util',
  48. 'source-map-support': 'commonjs source-map-support',
  49. 'windows-swca': 'commonjs windows-swca',
  50. 'windows-native-registry': 'commonjs windows-native-registry',
  51. 'windows-blurbehind': 'commonjs windows-blurbehind',
  52. 'yargs/yargs': 'commonjs yargs/yargs',
  53. },
  54. plugins: [
  55. new webpack.optimize.ModuleConcatenationPlugin(),
  56. new webpack.DefinePlugin({
  57. 'process.type': '"main"',
  58. }),
  59. ],
  60. }
  61. if (process.env.BUNDLE_ANALYZER) {
  62. module.exports.plugins.push(new BundleAnalyzerPlugin())
  63. }