forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.cjs
More file actions
100 lines (92 loc) · 2.55 KB
/
webpack.config.cjs
File metadata and controls
100 lines (92 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const Dotenv = require("dotenv-webpack");
const sourceDirectoryPath = path.resolve(__dirname, "src");
// Directory under which the final webpacked output will be saved.
const bundleDirectoryPath = path.resolve(__dirname, "dist", "bundle");
module.exports = {
mode: "development", // TODO: production
devtool: "inline-source-map", // TODO: remove this
entry: {
// The Devtools script and view
"devtools/DevtoolsScript": path.join(sourceDirectoryPath, "devtools", "DevtoolsScript.ts"),
"devtools/InitializeViewScript": path.join(
sourceDirectoryPath,
"devtools",
"InitializeViewScript.ts",
),
// The Background script
"background/BackgroundScript": path.join(
sourceDirectoryPath,
"background",
"BackgroundScript.ts",
),
// The Content script
"content/ContentScript": path.join(sourceDirectoryPath, "content", "ContentScript.ts"),
// The action button pop-up script
"popup/PopupScript": path.join(sourceDirectoryPath, "popup", "PopupScript.ts"),
},
output: {
path: bundleDirectoryPath,
filename: "[name].js",
publicPath: "",
},
resolve: {
extensionAlias: {
".cjs": [".cts", ".cjs"],
".js": [".ts", ".tsx", ".js"],
".mjs": [".mts", ".mjs"],
},
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
module: {
rules: [
{
test: /\.m?js/,
type: "javascript/auto",
},
{
test: /\.m?js/,
resolve: {
// Required until all transitive dependencies are fully ESM.
// https://webpack.js.org/configuration/module/#resolvefullyspecified
fullySpecified: false,
},
},
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
resolve: {
// Required until all transitive dependencies are fully ESM.
// https://webpack.js.org/configuration/module/#resolvefullyspecified
fullySpecified: false,
},
},
],
},
plugins: [
new webpack.ProvidePlugin({
process: "process/browser.js",
}),
new CopyPlugin({
patterns: [
// Copy assets from `public`
{ from: ".", to: ".", context: "public" },
// Copy HTML resources from source
{ from: "**/*.html", to: ".", context: "src" },
],
}),
new Dotenv({
path: "./.env",
systemvars: true,
// Suppress missing .env warning in CI; keep it locally so devs know to create .env.
silent: Boolean(process.env.CI || process.env.TF_BUILD),
}),
],
};