Files
firefox/devtools/client/debugger/webpack.config.js
T
Nicolas Chevobbe dcd129b069 Bug 1586658 - Update debugger bundle files.r=jlast.
Those files are generated with bin/bundle.js, and were
out of sync.
We take this as an opportunity to include the license
at the top of the files, using the Webpack Banner plugin.

Differential Revision: https://phabricator.services.mozilla.com/D48297
2019-10-08 21:28:18 +00:00

102 lines
3.3 KiB
JavaScript

/* 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 toolbox = require("devtools-launchpad/index");
const sourceMapAssets = require("devtools-source-map/assets");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const getConfig = require("./bin/getConfig");
const mozillaCentralMappings = require("./configs/mozilla-central-mappings");
const path = require("path");
const ObjectRestSpreadPlugin = require("@sucrase/webpack-object-rest-spread-plugin");
const isProduction = process.env.NODE_ENV === "production";
/*
* builds a path that's relative to the project path
* returns an array so that we can prepend
* hot-module-reloading in local development
*/
function getEntry(filename) {
return [path.join(__dirname, filename)];
}
const webpackConfig = {
entry: {
// We always generate the debugger bundle, but we will only copy the CSS
// artifact over to mozilla-central.
"parser-worker": getEntry("src/workers/parser/worker.js"),
"pretty-print-worker": getEntry("src/workers/pretty-print/worker.js"),
"search-worker": getEntry("src/workers/search/worker.js"),
"source-map-worker": getEntry("packages/devtools-source-map/src/worker.js"),
"source-map-index": getEntry("packages/devtools-source-map/src/index.js"),
},
output: {
path: path.join(__dirname, "assets/build"),
filename: "[name].js",
publicPath: "/assets/build",
},
plugins: [
new CopyWebpackPlugin(
Object.entries(sourceMapAssets).map(([name, filePath]) => ({
from: filePath,
to: `source-map-worker-assets/${name}`,
}))
),
new webpack.BannerPlugin({
banner: `/* 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/. */
`,
raw: true,
exclude: /\.css$/,
}),
],
};
if (isProduction) {
// In the firefox panel, build the vendored dependencies as a bundle instead,
// the other debugger modules will be transpiled to a format that is
// compatible with the DevTools Loader.
webpackConfig.entry.vendors = getEntry("src/vendors.js");
webpackConfig.entry.reps = getEntry("packages/devtools-reps/src/index.js");
} else {
webpackConfig.entry.debugger = getEntry("src/main.development.js");
}
const envConfig = getConfig();
const extra = {
babelIncludes: ["react-aria-components"],
};
webpackConfig.plugins.push(new ObjectRestSpreadPlugin());
if (!isProduction) {
webpackConfig.module = webpackConfig.module || {};
webpackConfig.module.rules = webpackConfig.module.rules || [];
} else {
webpackConfig.output.libraryTarget = "umd";
extra.excludeMap = mozillaCentralMappings;
extra.recordsPath = "bin/module-manifest.json";
}
const overallConfig = toolbox.toolboxConfig(webpackConfig, envConfig, extra);
for (const rule of overallConfig.module.rules) {
// The launchpad still uses Babel 6. Rewrite it to use the local Babel 7
// install instead.
if (rule.loader === "babel-loader?ignore=src/lib") {
rule.loader = require.resolve("babel-loader");
rule.options = {
ignore: ["src/lib"],
};
}
}
module.exports = overallConfig;