webpack.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. module.exports = {
  4. name: 'terminus',
  5. target: 'node',
  6. entry: {
  7. 'index.ignore': 'file-loader?name=index.html!val-loader!pug-html-loader!' + path.resolve(__dirname, './index.pug'),
  8. 'preload': path.resolve(__dirname, 'src/entry.preload.ts'),
  9. 'bundle': path.resolve(__dirname, 'src/entry.ts'),
  10. },
  11. mode: process.env.DEV ? 'development' : 'production',
  12. context: __dirname,
  13. devtool: 'source-map',
  14. output: {
  15. path: path.join(__dirname, 'dist'),
  16. pathinfo: true,
  17. filename: '[name].js'
  18. },
  19. resolve: {
  20. modules: ['src/', 'node_modules', '../node_modules', 'assets/'].map(x => path.join(__dirname, x)),
  21. extensions: ['.ts', '.js'],
  22. },
  23. module: {
  24. rules: [
  25. {
  26. test: /\.ts$/,
  27. use: {
  28. loader: 'awesome-typescript-loader',
  29. options: {
  30. configFileName: path.resolve(__dirname, 'tsconfig.json'),
  31. }
  32. }
  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. ],
  78. }