webpack.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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(
  14. entries.map((entry) => [
  15. entry,
  16. path.join(__dirname, "./Extensions/combined/", `${entry}.js`),
  17. ])
  18. ),
  19. output: {
  20. filename: "[name].js",
  21. path: path.resolve(__dirname, "Extensions/combined/dist"),
  22. clean: true,
  23. },
  24. optimization: {
  25. minimize: false,
  26. },
  27. watchOptions: {
  28. ignored: "**/dist/**",
  29. },
  30. plugins: [
  31. // exclude locale files in moment
  32. new CopyPlugin({
  33. patterns: [
  34. {
  35. from: "./Extensions/combined",
  36. to: "./chrome",
  37. globOptions: {
  38. ignore: ignorePatterns,
  39. },
  40. },
  41. {
  42. from: "./Extensions/combined/manifest-chrome.json",
  43. to: "./chrome/manifest.json",
  44. },
  45. {
  46. from: "./Extensions/combined",
  47. to: "./firefox",
  48. globOptions: {
  49. ignore: ignorePatterns,
  50. },
  51. },
  52. {
  53. from: "./Extensions/combined/manifest-firefox.json",
  54. to: "./firefox/manifest.json",
  55. },
  56. ],
  57. }),
  58. new FileManagerPlugin({
  59. events: {
  60. onEnd: {
  61. copy: [
  62. {
  63. source: "./Extensions/combined/dist/**.js",
  64. destination: "./Extensions/combined/dist/firefox/",
  65. },
  66. {
  67. source: "./Extensions/combined/dist/**.js",
  68. destination: "./Extensions/combined/dist/chrome/",
  69. },
  70. ],
  71. },
  72. },
  73. }),
  74. ],
  75. };