webpack.config.renderer.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. const HtmlWebpackPlugin = require('html-webpack-plugin');
  2. const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
  3. const CopyPlugin = require('copy-webpack-plugin');
  4. let config = {
  5. devtool: 'source-map',
  6. mode: 'production',
  7. target: "electron-renderer",
  8. entry: {
  9. index: "./src/renderer/index.js",
  10. serial: "./src/renderer/handler.js",
  11. about: "./src/renderer/about.js",
  12. esptools: "./src/renderer/esptools.js",
  13. update: "./src/renderer/update.js"
  14. },
  15. output: {
  16. path: __dirname + "/dist/renderer/",
  17. filename: "[name].js"
  18. },
  19. optimization: {
  20. minimize: false,
  21. // minimizer: [
  22. // new UglifyJSPlugin({
  23. // parallel: true,
  24. // sourceMap: true
  25. // })
  26. // ],
  27. splitChunks: {
  28. chunks: 'all',
  29. minSize: 30000,
  30. minChunks: 1,
  31. maxAsyncRequests: 5,
  32. maxInitialRequests: 3,
  33. name: 'lib.min'
  34. },
  35. runtimeChunk: {
  36. name: 'lib.min'
  37. }
  38. },
  39. plugins: [
  40. new HtmlWebpackPlugin({
  41. filename: "index.html",
  42. template: "./src/renderer/assets/template.ejs",
  43. chunks: ['lib.min', 'index']
  44. }),
  45. new HtmlWebpackPlugin({
  46. filename: "serialport.html",
  47. template: "./src/renderer/assets/template.ejs",
  48. chunks: ['lib.min', 'serial']
  49. }),
  50. new HtmlWebpackPlugin({
  51. filename: "aboutus.html",
  52. template: "./src/renderer/assets/aboutus.ejs",
  53. title: "About Us",
  54. chunks: ['lib.min', 'about']
  55. }),
  56. new HtmlWebpackPlugin({
  57. filename: "esptools.html",
  58. template: "./src/renderer/assets/esptools.ejs",
  59. title: "Esptools",
  60. chunks: ['lib.min', 'esptools']
  61. }),
  62. new HtmlWebpackPlugin({
  63. filename: "update.html",
  64. template: "./src/renderer/assets/update.ejs",
  65. title: "Update",
  66. chunks: ['lib.min', 'update']
  67. }),
  68. new HtmlWebpackPlugin({
  69. filename: "upload.html",
  70. template: "./src/renderer/assets/template.ejs",
  71. chunks: ['lib.min', 'upload']
  72. }),
  73. new CopyPlugin({
  74. patterns: [
  75. { from: __dirname + "/src/renderer/assets/upload_error.json" }]
  76. }),
  77. new CopyPlugin({
  78. patterns: [
  79. { from: __dirname + "/src/static/common/ccrb.key" }]
  80. }),
  81. new CopyPlugin({
  82. patterns: [
  83. { from: __dirname + "/src/renderer/cocoblockly-x/", to: "cocoblockly-x/" }]
  84. }),
  85. new CopyPlugin({
  86. patterns: [
  87. { from: __dirname + "/src/static/common/ccrb.crt" }]
  88. })
  89. ]
  90. };
  91. module.exports = config;