summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/webpack.system-addon.config.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/newtab/webpack.system-addon.config.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/newtab/webpack.system-addon.config.js')
-rw-r--r--browser/components/newtab/webpack.system-addon.config.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/browser/components/newtab/webpack.system-addon.config.js b/browser/components/newtab/webpack.system-addon.config.js
new file mode 100644
index 0000000000..6cbe9e60cc
--- /dev/null
+++ b/browser/components/newtab/webpack.system-addon.config.js
@@ -0,0 +1,80 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const path = require("path");
+const webpack = require("webpack");
+const { ResourceUriPlugin } = require("./tools/resourceUriPlugin");
+
+const absolute = relPath => path.join(__dirname, relPath);
+
+const resourcePathRegEx = /^resource:\/\/activity-stream\//;
+
+module.exports = (env = {}) => ({
+ mode: "none",
+ entry: absolute("content-src/activity-stream.jsx"),
+ output: {
+ path: absolute("data/content"),
+ filename: "activity-stream.bundle.js",
+ library: "NewtabRenderUtils",
+ },
+ // TODO: switch to eval-source-map for faster builds. Requires CSP changes
+ devtool: env.development ? "inline-source-map" : false,
+ plugins: [
+ // The ResourceUriPlugin handles translating resource URIs in import
+ // statements in .mjs files, in a similar way to what babel-jsm-to-commonjs
+ // does for jsm files.
+ new ResourceUriPlugin({ resourcePathRegEx }),
+ new webpack.BannerPlugin(
+ `THIS FILE IS AUTO-GENERATED: ${path.basename(__filename)}`
+ ),
+ new webpack.optimize.ModuleConcatenationPlugin(),
+ ],
+ module: {
+ rules: [
+ {
+ test: /\.jsx?$/,
+ exclude: /node_modules\/(?!@fluent\/).*/,
+ loader: "babel-loader",
+ options: {
+ presets: ["@babel/preset-react"],
+ plugins: ["@babel/plugin-proposal-optional-chaining"],
+ },
+ },
+ {
+ test: /\.jsm$/,
+ exclude: /node_modules/,
+ loader: "babel-loader",
+ // Converts .jsm files into common-js modules
+ options: {
+ plugins: [
+ [
+ "./tools/babel-jsm-to-commonjs.js",
+ {
+ basePath: resourcePathRegEx,
+ removeOtherImports: true,
+ replace: true,
+ },
+ ],
+ ],
+ },
+ },
+ ],
+ },
+ // This resolve config allows us to import with paths relative to the root directory, e.g. "lib/ActivityStream.jsm"
+ resolve: {
+ extensions: [".js", ".jsx"],
+ modules: ["node_modules", "."],
+ fallback: {
+ stream: require.resolve("stream-browserify"),
+ },
+ },
+ externals: {
+ "prop-types": "PropTypes",
+ react: "React",
+ "react-dom": "ReactDOM",
+ redux: "Redux",
+ "react-redux": "ReactRedux",
+ "react-transition-group": "ReactTransitionGroup",
+ },
+});