webpack.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const path = require("path");
  2. const CopyPlugin = require("copy-webpack-plugin");
  3. const FileManagerPlugin = require("filemanager-webpack-plugin");
  4. const entries = ['ryd.content-script', 'ryd.background', 'popup'];
  5. const ignorePatterns = [
  6. "**/manifest-**",
  7. "**/dist/**",
  8. "**/src/**",
  9. "**/readme.md",
  10. ...entries.map(entry => `**/${entry}.js`)
  11. ];
  12. module.exports = {
  13. entry: Object.fromEntries(entries.map(entry => [entry, path.join(__dirname, './Extensions/combined/', `${entry}.js`)])),
  14. output: {
  15. filename: "[name].js",
  16. path: path.resolve(__dirname, "Extensions/combined/dist"),
  17. clean: true,
  18. },
  19. optimization: {
  20. minimize: false,
  21. },
  22. watchOptions: {
  23. ignored: "**/dist/**",
  24. },
  25. plugins: [
  26. // exclude locale files in moment
  27. new CopyPlugin({
  28. patterns: [
  29. {
  30. from: "./Extensions/combined",
  31. to: "./chrome",
  32. globOptions: {
  33. ignore: ignorePatterns,
  34. },
  35. },
  36. {
  37. from: "./Extensions/combined/manifest-chrome.json",
  38. to: "./chrome/manifest.json",
  39. },
  40. {
  41. from: "./Extensions/combined",
  42. to: "./firefox",
  43. globOptions: {
  44. ignore: ignorePatterns,
  45. },
  46. },
  47. {
  48. from: "./Extensions/combined/manifest-firefox.json",
  49. to: "./firefox/manifest.json",
  50. },
  51. ],
  52. }),
  53. new FileManagerPlugin({
  54. events: {
  55. onEnd: {
  56. copy: [
  57. {
  58. source: "./Extensions/combined/dist/**.js",
  59. destination:
  60. "./Extensions/combined/dist/firefox/",
  61. },
  62. {
  63. source: "./Extensions/combined/dist/**.js",
  64. destination:
  65. "./Extensions/combined/dist/chrome/",
  66. },
  67. ],
  68. },
  69. },
  70. }),
  71. ],
  72. };