webpack.common.js 783 B

1234567891011121314151617181920212223242526272829303132333435
  1. const path = require("path");
  2. require("dotenv").config({
  3. path: path.join(__dirname, ".env"),
  4. });
  5. const EncryptPlugin = require("ricochetjs").EncryptPlugin;
  6. const Dotenv = require("dotenv-webpack");
  7. const SECRET_KEY = process.env.RICOCHET_SITE_KEY;
  8. if (!SECRET_KEY) {
  9. console.log(
  10. "You must define a RICOCHET_SITE_KEY env variable.\n" +
  11. "If you don't have any key, please visit the Ricochet.js admin panel to create one."
  12. );
  13. process.exit(-1);
  14. }
  15. module.exports = {
  16. entry: "./src/index.js",
  17. target: "node",
  18. devtool: false,
  19. output: {
  20. path: path.resolve(__dirname, "../public"),
  21. filename: "ricochet.json",
  22. library: {
  23. type: "commonjs",
  24. },
  25. },
  26. plugins: [
  27. new Dotenv(),
  28. new EncryptPlugin({
  29. key: SECRET_KEY,
  30. }),
  31. ],
  32. };