a small private-blog service

webpack.common.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. const webpack = require('webpack');
  2. const CopyWebpackPlugin = require('copy-webpack-plugin');
  3. const HtmlWebpackPlugin = require('html-webpack-plugin');
  4. const rxPaths = require('rxjs/_esm5/path-mapping');
  5. const utils = require('./utils.js');
  6. module.exports = (options) => ({
  7. resolve: {
  8. extensions: ['.ts', '.js'],
  9. modules: ['node_modules'],
  10. alias: {
  11. app: utils.root('src/main/webapp/app/'),
  12. ...rxPaths()
  13. }
  14. },
  15. stats: {
  16. children: false
  17. },
  18. module: {
  19. rules: [
  20. {
  21. test: /\.html$/,
  22. loader: 'html-loader',
  23. options: {
  24. minimize: true,
  25. caseSensitive: true,
  26. removeAttributeQuotes:false,
  27. minifyJS:false,
  28. minifyCSS:false
  29. },
  30. exclude: /(src\/main\/webapp\/index.html)/
  31. },
  32. {
  33. test: /\.(jpe?g|png|gif|svg|woff2?|ttf|eot)$/i,
  34. loader: 'file-loader',
  35. options: {
  36. digest: 'hex',
  37. hash: 'sha512',
  38. name: 'content/[hash].[ext]'
  39. }
  40. },
  41. {
  42. test: /manifest.webapp$/,
  43. loader: 'file-loader',
  44. options: {
  45. name: 'manifest.webapp'
  46. }
  47. },
  48. // Ignore warnings about System.import in Angular
  49. { test: /[\/\\]@angular[\/\\].+\.js$/, parser: { system: true } },
  50. ]
  51. },
  52. plugins: [
  53. new webpack.DefinePlugin({
  54. 'process.env': {
  55. NODE_ENV: `'${options.env}'`,
  56. BUILD_TIMESTAMP: `'${new Date().getTime()}'`,
  57. VERSION: `'${utils.parseVersion()}'`,
  58. DEBUG_INFO_ENABLED: options.env === 'development',
  59. // The root URL for API calls, ending with a '/' - for example: `"https://www.jhipster.tech:8081/myservice/"`.
  60. // If this URL is left empty (""), then it will be relative to the current context.
  61. // If you use an API server, in `prod` mode, you will need to enable CORS
  62. // (see the `jhipster.cors` common JHipster property in the `application-*.yml` configurations)
  63. SERVER_API_URL: `''`
  64. }
  65. }),
  66. new CopyWebpackPlugin([
  67. { from: './node_modules/swagger-ui/dist/css', to: 'swagger-ui/dist/css' },
  68. { from: './node_modules/swagger-ui/dist/lib', to: 'swagger-ui/dist/lib' },
  69. { from: './node_modules/swagger-ui/dist/swagger-ui.min.js', to: 'swagger-ui/dist/swagger-ui.min.js' },
  70. { from: './src/main/webapp/swagger-ui/', to: 'swagger-ui' },
  71. { from: './src/main/webapp/content/', to: 'content' },
  72. { from: './src/main/webapp/favicon.ico', to: 'favicon.ico' },
  73. { from: './src/main/webapp/manifest.webapp', to: 'manifest.webapp' },
  74. // jhipster-needle-add-assets-to-webpack - JHipster will add/remove third-party resources in this array
  75. { from: './src/main/webapp/robots.txt', to: 'robots.txt' }
  76. ]),
  77. new HtmlWebpackPlugin({
  78. template: './src/main/webapp/index.html',
  79. chunks: ['vendors', 'polyfills', 'main', 'global'],
  80. chunksSortMode: 'manual',
  81. inject: 'body'
  82. })
  83. ]
  84. });