webpack.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const path = require("path");
  2. const CircularDependencyPlugin = require("circular-dependency-plugin");
  3. const TerserPlugin = require("terser-webpack-plugin");
  4. module.exports = {
  5. mode: "development",
  6. target: "node",
  7. devtool: "inline-source-map",
  8. entry: "./src/index.js",
  9. output: {
  10. filename: "main.js",
  11. path: path.resolve(__dirname, "js"),
  12. library: "BetterDiscord",
  13. libraryTarget: "commonjs2"
  14. },
  15. externals: {
  16. electron: `electron`,
  17. fs: `fs`,
  18. path: `path`,
  19. events: `events`,
  20. rimraf: `rimraf`,
  21. yauzl: `yauzl`,
  22. mkdirp: `mkdirp`,
  23. request: `request`,
  24. "node-fetch": "node-fetch"
  25. },
  26. resolve: {
  27. extensions: [".js", ".jsx"],
  28. modules: [
  29. path.resolve("src", "builtins"),
  30. path.resolve("src", "modules")
  31. ],
  32. alias: {
  33. react$: path.resolve(__dirname, "src", "react.js"),
  34. "react-dom$": path.resolve(__dirname, "src", "react-dom.js")
  35. }
  36. },
  37. module: {
  38. rules: [
  39. {
  40. test: /\.jsx?$/,
  41. loader: "babel-loader",
  42. exclude: /node_modules/,
  43. query: {
  44. presets: [["@babel/env", {
  45. targets: {
  46. node: "12.8.1",
  47. chrome: "78"
  48. }
  49. }], "@babel/react"]
  50. }
  51. }
  52. ]
  53. },
  54. plugins: [
  55. new CircularDependencyPlugin({
  56. // exclude detection of files based on a RegExp
  57. exclude: /a\.js|node_modules/,
  58. // add errors to webpack instead of warnings
  59. // failOnError: true,
  60. // set the current working directory for displaying module paths
  61. cwd: process.cwd(),
  62. })
  63. ],
  64. optimization: {
  65. minimizer: [
  66. new TerserPlugin({
  67. terserOptions: {
  68. compress: {drop_debugger:false}
  69. }
  70. })
  71. ]
  72. }
  73. };