webpack.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { dirname, join } from "path";
  2. import { exec } from "child_process";
  3. import { fileURLToPath } from "url";
  4. export default {
  5. entry: "./src/BetterYTM.user.ts",
  6. mode: "production",
  7. // optimization: {
  8. // minimize: false,
  9. // },
  10. module: {
  11. rules: [
  12. {
  13. test: /\.tsx?$/,
  14. use: "ts-loader",
  15. exclude: /node_modules/,
  16. },
  17. {
  18. test: /\.html$/i,
  19. loader: "html-loader",
  20. },
  21. {
  22. test: /\.md$/,
  23. use: [
  24. {
  25. loader: "html-loader",
  26. },
  27. {
  28. loader: "markdown-loader",
  29. },
  30. ],
  31. },
  32. ],
  33. },
  34. plugins: [
  35. {
  36. apply: (compiler) => {
  37. compiler.hooks.afterEmit.tap("AfterEmitPlugin", () => {
  38. exec("npm run post-build", (_err, stdout, stderr) => {
  39. stdout && process.stdout.write(stdout);
  40. stderr && process.stderr.write(stderr);
  41. });
  42. });
  43. },
  44. },
  45. ],
  46. resolve: {
  47. extensions: [".ts", ".js"],
  48. },
  49. output: {
  50. filename: "BetterYTM.user.js",
  51. path: join(dirname(fileURLToPath(import.meta.url)), "/dist"),
  52. },
  53. };