a small private-blog service

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. const webpack = require('webpack');
  2. const writeFilePlugin = require('write-file-webpack-plugin');
  3. const webpackMerge = require('webpack-merge');
  4. const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
  5. const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
  6. const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
  7. const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
  8. const WebpackNotifierPlugin = require('webpack-notifier');
  9. const path = require('path');
  10. const utils = require('./utils.js');
  11. const commonConfig = require('./webpack.common.js');
  12. const ENV = 'development';
  13. module.exports = (options) => webpackMerge(commonConfig({ env: ENV }), {
  14. devtool: 'eval-source-map',
  15. devServer: {
  16. contentBase: './target/www',
  17. proxy: [{
  18. context: [
  19. /* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */
  20. '/api',
  21. '/management',
  22. '/swagger-resources',
  23. '/v2/api-docs',
  24. '/h2-console',
  25. '/auth'
  26. ],
  27. target: `http${options.tls ? 's' : ''}://127.0.0.1:8085`,
  28. secure: false,
  29. changeOrigin: options.tls,
  30. headers: { host: 'localhost:9000' }
  31. },{
  32. context: [
  33. '/websocket'
  34. ],
  35. target: 'ws://127.0.0.1:8085',
  36. ws: true
  37. }],
  38. stats: options.stats,
  39. watchOptions: {
  40. ignored: /node_modules/
  41. }
  42. },
  43. entry: {
  44. polyfills: './src/main/webapp/app/polyfills',
  45. global: './src/main/webapp/content/css/global.css',
  46. main: './src/main/webapp/app/app.main'
  47. },
  48. output: {
  49. path: utils.root('target/www'),
  50. filename: 'app/[name].bundle.js',
  51. chunkFilename: 'app/[id].chunk.js'
  52. },
  53. module: {
  54. rules: [{
  55. test: /\.ts$/,
  56. enforce: 'pre',
  57. loader: 'tslint-loader',
  58. exclude: [/(node_modules)/, new RegExp('reflect-metadata\\' + path.sep + 'Reflect\\.ts')]
  59. },
  60. {
  61. test: /\.ts$/,
  62. use: [
  63. 'angular2-template-loader',
  64. {
  65. loader: 'cache-loader',
  66. options: {
  67. cacheDirectory: path.resolve('target/cache-loader')
  68. }
  69. },
  70. {
  71. loader: 'thread-loader',
  72. options: {
  73. // there should be 1 cpu for the fork-ts-checker-webpack-plugin
  74. workers: require('os').cpus().length - 1
  75. }
  76. },
  77. {
  78. loader: 'ts-loader',
  79. options: {
  80. transpileOnly: true,
  81. happyPackMode: true
  82. }
  83. },
  84. 'angular-router-loader'
  85. ],
  86. exclude: /(node_modules)/
  87. },
  88. {
  89. test: /\.css$/,
  90. use: ['to-string-loader', 'css-loader'],
  91. exclude: /(vendor\.css|global\.css)/
  92. },
  93. {
  94. test: /(vendor\.css|global\.css)/,
  95. use: ['style-loader', 'css-loader']
  96. }]
  97. },
  98. stats: process.env.JHI_DISABLE_WEBPACK_LOGS ? 'none' : options.stats,
  99. plugins: [
  100. process.env.JHI_DISABLE_WEBPACK_LOGS
  101. ? null
  102. : new SimpleProgressWebpackPlugin({
  103. format: options.stats === 'minimal' ? 'compact' : 'expanded'
  104. }),
  105. new FriendlyErrorsWebpackPlugin(),
  106. new ForkTsCheckerWebpackPlugin(),
  107. new BrowserSyncPlugin({
  108. host: 'localhost',
  109. port: 9000,
  110. proxy: {
  111. target: 'http://localhost:9060',
  112. ws: true
  113. },
  114. socket: {
  115. clients: {
  116. heartbeatTimeout: 60000
  117. }
  118. }
  119. }, {
  120. reload: false
  121. }),
  122. new webpack.ContextReplacementPlugin(
  123. /angular(\\|\/)core(\\|\/)/,
  124. path.resolve(__dirname, './src/main/webapp')
  125. ),
  126. new writeFilePlugin(),
  127. new webpack.WatchIgnorePlugin([
  128. utils.root('src/test'),
  129. ]),
  130. new WebpackNotifierPlugin({
  131. title: 'JHipster',
  132. contentImage: path.join(__dirname, 'logo-jhipster.png')
  133. })
  134. ].filter(Boolean),
  135. mode: 'development'
  136. });