-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
71 lines (62 loc) · 2 KB
/
Copy pathwebpack.config.js
File metadata and controls
71 lines (62 loc) · 2 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
/**
* Custom Webpack Configuration for Agentic Admin
*
* Extends the default @wordpress/scripts config to add:
* - Service Worker as a separate entry point (no chunking, self-contained)
*
* @package
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const path = require( 'path' );
module.exports = {
...defaultConfig,
entry: {
// Main application bundle
index: path.resolve( __dirname, 'src/extensions/index.js' ),
// Gutenberg editor sidebar and admin-wide chat sidebar both disabled
// for v0.11 — UIs not finished, re-enable in v0.12 once polished.
// Sources preserved at src/extensions/editor.js and
// src/extensions/admin-sidebar.js.
// Service Worker - needs to be a self-contained bundle
sw: {
import: path.resolve( __dirname, 'src/extensions/sw.js' ),
filename: 'sw.js', // Output as sw.js directly, not sw.index.js
},
// Whisper Web Worker — source preserved in src/extensions/services/
// and src/extensions/components/VoiceButton.jsx for v1.4 (per roadmap).
// Re-add this entry to ship voice input again.
},
module: {
...defaultConfig.module,
rules: [
...defaultConfig.module.rules,
// Strip WebLLM's built-in model download addresses. The site owner
// configures the model source; see tools/strip-webllm-prebuilt-loader.js.
{
test: /[\\/]node_modules[\\/]@mlc-ai[\\/]web-llm[\\/]lib[\\/]index\.js$/,
use: path.resolve(
__dirname,
'tools/strip-webllm-prebuilt-loader.js'
),
},
],
},
output: {
...defaultConfig.output,
path: path.resolve( __dirname, 'build-extensions' ),
},
// Service Worker specific optimizations
optimization: {
...defaultConfig.optimization,
// Prevent code splitting for SW - it needs to be self-contained
splitChunks: {
...defaultConfig.optimization?.splitChunks,
cacheGroups: {
...defaultConfig.optimization?.splitChunks?.cacheGroups,
// Don't split the service worker
sw: false,
},
},
runtimeChunk: false, // SW needs runtime included
},
};