1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 const path = require("path");
6 const webpack = require("webpack");
7 const { ResourceUriPlugin } = require("./tools/resourceUriPlugin");
9 const absolute = relPath => path.join(__dirname, relPath);
11 const resourcePathRegEx = /^resource:\/\/activity-stream\//;
13 module.exports = (env = {}) => ({
15 entry: absolute("content-src/activity-stream.jsx"),
17 path: absolute("data/content"),
18 filename: "activity-stream.bundle.js",
19 library: "NewtabRenderUtils",
21 // TODO: switch to eval-source-map for faster builds. Requires CSP changes
22 devtool: env.development ? "inline-source-map" : false,
24 // The ResourceUriPlugin handles translating resource URIs in import
25 // statements in .mjs files, in a similar way to what babel-jsm-to-commonjs
26 // does for jsm files.
27 new ResourceUriPlugin({ resourcePathRegEx }),
28 new webpack.BannerPlugin(
29 `THIS FILE IS AUTO-GENERATED: ${path.basename(__filename)}`
31 new webpack.optimize.ModuleConcatenationPlugin(),
37 exclude: /node_modules\/(?!@fluent\/).*/,
38 loader: "babel-loader",
40 presets: ["@babel/preset-react"],
41 plugins: ["@babel/plugin-proposal-optional-chaining"],
46 exclude: /node_modules/,
47 loader: "babel-loader",
48 // Converts .jsm files into common-js modules
52 "./tools/babel-jsm-to-commonjs.js",
54 basePath: resourcePathRegEx,
55 removeOtherImports: true,
64 // This resolve config allows us to import with paths relative to the root directory, e.g. "lib/ActivityStream.jsm"
66 extensions: [".js", ".jsx"],
67 modules: ["node_modules", "."],
69 stream: require.resolve("stream-browserify"),
73 "prop-types": "PropTypes",
75 "react-dom": "ReactDOM",
77 "react-redux": "ReactRedux",
78 "react-transition-group": "ReactTransitionGroup",