webpack.config.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const { AngularCompilerPlugin } = require('@ngtools/webpack')
  4. module.exports = {
  5. name: 'terminus',
  6. target: 'node',
  7. entry: {
  8. 'index.ignore': 'file-loader?name=index.html!pug-html-loader!' + path.resolve(__dirname, './index.pug'),
  9. sentry: path.resolve(__dirname, 'lib/sentry.ts'),
  10. preload: path.resolve(__dirname, 'src/entry.preload.ts'),
  11. bundle: path.resolve(__dirname, 'src/entry.ts'),
  12. },
  13. mode: process.env.TERMINUS_DEV ? 'development' : 'production',
  14. optimization:{
  15. minimize: false,
  16. },
  17. context: __dirname,
  18. devtool: 'source-map',
  19. output: {
  20. path: path.join(__dirname, 'dist'),
  21. pathinfo: true,
  22. filename: '[name].js',
  23. },
  24. resolve: {
  25. modules: ['src/', 'node_modules', '../node_modules', 'assets/'].map(x => path.join(__dirname, x)),
  26. extensions: ['.ts', '.js'],
  27. },
  28. module: {
  29. rules: [
  30. {
  31. test: /(?:\.ngfactory\.js|\.ngfactory|\.ngstyle\.js|\.ts)$/,
  32. loader: '@ngtools/webpack',
  33. },
  34. { test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
  35. { test: /\.css$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
  36. {
  37. test: /\.(png|svg)$/,
  38. use: {
  39. loader: 'file-loader',
  40. options: {
  41. name: 'images/[name].[ext]',
  42. },
  43. },
  44. },
  45. {
  46. test: /\.(ttf|eot|otf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  47. use: {
  48. loader: 'file-loader',
  49. options: {
  50. name: 'fonts/[name].[ext]',
  51. },
  52. },
  53. },
  54. ],
  55. },
  56. externals: {
  57. '@angular/core': 'commonjs @angular/core',
  58. '@angular/compiler': 'commonjs @angular/compiler',
  59. '@angular/platform-browser': 'commonjs @angular/platform-browser',
  60. '@angular/platform-browser-dynamic': 'commonjs @angular/platform-browser-dynamic',
  61. '@angular/forms': 'commonjs @angular/forms',
  62. '@angular/common': 'commonjs @angular/common',
  63. '@ng-bootstrap/ng-bootstrap': 'commonjs @ng-bootstrap/ng-bootstrap',
  64. child_process: 'commonjs child_process',
  65. electron: 'commonjs electron',
  66. 'electron-is-dev': 'commonjs electron-is-dev',
  67. fs: 'commonjs fs',
  68. 'ngx-toastr': 'commonjs ngx-toastr',
  69. module: 'commonjs module',
  70. mz: 'commonjs mz',
  71. path: 'commonjs path',
  72. rxjs: 'commonjs rxjs',
  73. 'zone.js': 'commonjs zone.js/dist/zone.js',
  74. },
  75. plugins: [
  76. new webpack.optimize.ModuleConcatenationPlugin(),
  77. new webpack.DefinePlugin({
  78. 'process.type': '"renderer"'
  79. }),
  80. new AngularCompilerPlugin({
  81. tsConfigPath: path.resolve(__dirname, 'tsconfig.json'),
  82. entryModule: 'src/index#default',
  83. sourceMap: true,
  84. }),
  85. ],
  86. }