webpack.system-addon.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. const absolute = relPath => path.join(__dirname, relPath);
  4. const resourcePathRegEx = /^resource:\/\/activity-stream\//;
  5. module.exports = (env = {}) => ({
  6. mode: "none",
  7. entry: absolute("content-src/activity-stream.jsx"),
  8. output: {
  9. path: absolute("data/content"),
  10. filename: "activity-stream.bundle.js",
  11. },
  12. // TODO: switch to eval-source-map for faster builds. Requires CSP changes
  13. devtool: env.development ? "inline-source-map" : false,
  14. plugins: [new webpack.optimize.ModuleConcatenationPlugin()],
  15. module: {
  16. rules: [
  17. {
  18. test: /\.jsx?$/,
  19. exclude: /node_modules\/(?!(fluent|fluent-react)\/).*/,
  20. loader: "babel-loader",
  21. options: {
  22. presets: ["@babel/preset-react"],
  23. plugins: [
  24. ["@babel/plugin-proposal-async-generator-functions"],
  25. ],
  26. },
  27. },
  28. {
  29. test: /\.jsm$/,
  30. exclude: /node_modules/,
  31. loader: "babel-loader",
  32. // Converts .jsm files into common-js modules
  33. options: {plugins: [["jsm-to-esmodules", {basePath: resourcePathRegEx, removeOtherImports: true, replace: true}]]},
  34. },
  35. ],
  36. },
  37. // This resolve config allows us to import with paths relative to the root directory, e.g. "lib/ActivityStream.jsm"
  38. resolve: {
  39. extensions: [".js", ".jsx"],
  40. modules: [
  41. "node_modules",
  42. ".",
  43. ],
  44. },
  45. externals: {
  46. "prop-types": "PropTypes",
  47. "react": "React",
  48. "react-dom": "ReactDOM",
  49. "react-intl": "ReactIntl",
  50. "redux": "Redux",
  51. "react-redux": "ReactRedux",
  52. },
  53. });