tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

webpack.system-addon.config.js (2246B)


      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/. */
      4 
      5 const path = require("path");
      6 const webpack = require("webpack");
      7 const { ResourceUriPlugin } = require("../../tools/resourceUriPlugin");
      8 const { MozSrcUriPlugin } = require("../../tools/mozsrcUriPlugin");
      9 
     10 const absolute = relPath => path.join(__dirname, relPath);
     11 
     12 module.exports = (env = {}) => ({
     13  mode: "none",
     14  entry: absolute("content-src/activity-stream.jsx"),
     15  output: {
     16    path: absolute("data/content"),
     17    filename: "activity-stream.bundle.js",
     18    library: "NewtabRenderUtils",
     19  },
     20  devtool: env.development ? "inline-source-map" : false,
     21  plugins: [
     22    // The ResourceUriPlugin handles translating resource URIs in import
     23    // statements in .mjs files to paths on the filesystem.
     24    new ResourceUriPlugin({
     25      resourcePathRegExes: [
     26        [new RegExp("^resource://newtab/"), path.join(__dirname, "./")],
     27        [
     28          new RegExp("^resource:///modules/topsites/"),
     29          path.join(__dirname, "../../components/topsites/"),
     30        ],
     31        [
     32          new RegExp("^resource:///modules/Dedupe.sys.mjs"),
     33          path.join(__dirname, "../../modules/Dedupe.sys.mjs"),
     34        ],
     35      ],
     36    }),
     37    new MozSrcUriPlugin({ baseDir: path.join(__dirname, "..", "..", "..") }),
     38    new webpack.BannerPlugin(
     39      `THIS FILE IS AUTO-GENERATED: ${path.basename(__filename)}`
     40    ),
     41    new webpack.optimize.ModuleConcatenationPlugin(),
     42  ],
     43  module: {
     44    rules: [
     45      {
     46        test: /\.jsx?$/,
     47        exclude: /node_modules\/(?!@fluent\/).*/,
     48        loader: "babel-loader",
     49        options: {
     50          presets: ["@babel/preset-react"],
     51        },
     52      },
     53    ],
     54  },
     55  // This resolve config allows us to import with paths relative to the root directory, e.g. "lib/ActivityStream.sys.mjs"
     56  resolve: {
     57    extensions: [".js", ".jsx", ".mjs"],
     58    modules: ["node_modules", "."],
     59  },
     60  externals: {
     61    "prop-types": "PropTypes",
     62    react: "React",
     63    "react-dom": "ReactDOM",
     64    redux: "Redux",
     65    "react-redux": "ReactRedux",
     66    "react-transition-group": "ReactTransitionGroup",
     67  },
     68 });