vue.config.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2018-2025, lengleng All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the pig4cloud.com developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: lengleng (wangiegie@gmail.com)
  16. */
  17. const {resolve} = require('path');
  18. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  19. const CopyPlugin = require('copy-webpack-plugin');
  20. module.exports = {
  21. baseUrl: './',
  22. outputDir: './src/main/resources/ui',
  23. assetsDir: 'assets',
  24. pages: {
  25. 'sba-core': {
  26. entry: './src/main/frontend/index.js',
  27. template: './src/main/frontend/index.html',
  28. filename: 'index.html'
  29. },
  30. 'login': {
  31. entry: './src/main/frontend/login.js',
  32. template: './src/main/frontend/login.html',
  33. filename: 'login.html'
  34. }
  35. },
  36. chainWebpack: config => {
  37. config.resolve.alias.set('@', resolve(__dirname, 'src/main/frontend'));
  38. config.module.rule('html')
  39. .test(/\.html$/)
  40. .use('html-loader')
  41. .loader('html-loader')
  42. .options({
  43. root: resolve(__dirname, 'src/main/frontend'),
  44. attrs: []
  45. })
  46. .end();
  47. config.plugin('prefetch-sba-core')
  48. .tap(args => {
  49. args[0].fileBlacklist = [/\.map$/, /event-source-polyfill\.?[a-z0-9]*\.js/];
  50. return args;
  51. });
  52. config.plugin('preload-login')
  53. .tap(args => {
  54. args[0].include.entries = [];
  55. return args;
  56. });
  57. config.plugin('prefetch-login')
  58. .tap(args => {
  59. args[0].include.entries = [];
  60. return args;
  61. });
  62. config.plugin('define')
  63. .tap(args => {
  64. args[0]['__PROJECT_VERSION__'] = `'${process.env.PROJECT_VERSION || ''}'`;
  65. return args;
  66. });
  67. },
  68. configureWebpack: {
  69. plugins: [
  70. new CopyPlugin([{
  71. from: resolve(__dirname, 'src/main/frontend/assets'),
  72. to: resolve(__dirname, './src/main/resources/ui/assets'),
  73. toType: 'dir',
  74. ignore: ['*.scss']
  75. }]),
  76. new BundleAnalyzerPlugin({
  77. analyzerMode: 'static',
  78. openAnalyzer: false,
  79. reportFilename: '../report.html'
  80. })
  81. ]
  82. }
  83. };