-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-webpack.config.ts
More file actions
72 lines (70 loc) · 2.44 KB
/
custom-webpack.config.ts
File metadata and controls
72 lines (70 loc) · 2.44 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
// see https://www.npmjs.com/package/@angular-builders/custom-webpack
import type { Configuration } from "webpack";
import webpack from "webpack";
// Note: AJV transforms/compiles a JSON Schema to an actual JS function. You can then call that function
// to validate input against said schema. BUT, to generate the function AJV uses dynamic code
// evaluation, which means doing this at runtime exposes us to the risk of code injection. To avoid
// this (and the need to add 'unsafe-eval' to our CSP in manifest.json) we use webpack's compile hook
// hook to "pre-compile" our validator function(s).
import { compile } from "./utils/ajv-utils";
export default {
entry: {
background: "src/background.ts",
content: "src/content.ts",
},
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
require('@tailwindcss/postcss'),
],
},
},
},
],
},
],
},
plugins: [
new webpack.NormalModuleReplacementPlugin(
/^node:/,
(resource) => {
resource.request = resource.request.replace(/^node:/, '');
}
),
{
apply: (compiler) => {
compiler.hooks.compile.tap("AjvPlugin", (_params) => {
compile({ schema: "src/schemas/settings.json", useDefaults: true });
});
},
},
],
optimization: {
runtimeChunk: false,
},
node: {
global: true, // Fix for "Uncaught ReferenceError: global is not defined" when importing Pinecone
},
experiments: {
topLevelAwait: true, // Fix for "Module parse failed: The top-level-await experiment is not enabled" when instantiating PineconeStore
},
resolve: {
fallback: {
// The assistant and chat streaming features in @pinecone-database/pinecone v5+ use the built-in Node.js 'fs',
// 'path' and 'stream' modules but these are not available in the browser environment. When webpack encounters
// imports for these modules it tries to find browser-compatible polyfills for them, fails, and throws
// "Module not found" errors. We're not using these features so just set these fallbacks to false, telling webpack to
// ignore these imports and not attempt to polyfill them for the browser.
fs: false,
path: false,
stream: false,
},
},
} as Configuration;