-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
198 lines (186 loc) · 5.54 KB
/
Copy pathwebpack.config.js
File metadata and controls
198 lines (186 loc) · 5.54 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
return {
entry: './src/stimulus-entry.ts',
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? 'source-map' : 'eval-source-map',
// Performance optimizations
performance: {
hints: isProduction ? 'warning' : false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: [
/node_modules/,
/__tests__/,
/src\/core\/ZeroPoint\.ts$/,
/src\/core\/NetworkNode\.ts$/,
/src\/core\/BrowserNetworkNode\.ts$/,
/src\/api\//,
/src\/monitoring\//,
/src\/utils\/GitIntegration\.ts$/,
/src\/utils\/ResourceCleanup\.ts$/,
/src\/core\/UnifiedSystem\.ts$/,
/src\/core\/UnifiedMetaphysicalInterface\.ts$/,
/src\/core\/PatternRecognition\.ts$/,
/src\/core\/PatternRegistry\.ts$/,
/src\/core\/Observer\.ts$/,
/src\/core\/CoilMixin\.ts$/,
/src\/core\/CoilSystem\.ts$/,
/src\/core\/InfiniteDimensionalRefactor\.ts$/,
/src\/field\//,
/src\/void\//,
/src\/unity\//,
/src\/integrity\//,
/src\/consciousness\/SelfEvolvingConsciousness\.ts$/
],
},
// Add CSS optimization
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader']
}
],
},
resolve: {
extensions: ['.ts', '.js'],
fallback: {
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"util": require.resolve("util/"),
"buffer": require.resolve("buffer/"),
"path": require.resolve("path-browserify"),
"url": require.resolve("url/"),
"querystring": require.resolve("querystring-es3"),
"fs": false,
"net": false,
"http": false,
"https": false,
"zlib": false,
"child_process": false,
"events": require.resolve("events/"),
},
},
// Consciousness-aware code splitting
optimization: {
minimize: isProduction,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: isProduction,
drop_debugger: isProduction
},
mangle: true
}
})
],
splitChunks: {
chunks: 'all',
cacheGroups: {
// Consciousness modules
consciousness: {
test: /[\\/]consciousness[\\/]/,
name: 'consciousness',
chunks: 'all',
priority: 20
},
// Metaphysical modules
metaphysics: {
test: /[\\/]metaphysics[\\/]/,
name: 'metaphysics',
chunks: 'all',
priority: 20
},
// Mathematical modules
mathematics: {
test: /[\\/]math[\\/]/,
name: 'mathematics',
chunks: 'all',
priority: 15
},
// Core modules
core: {
test: /[\\/]core[\\/]/,
name: 'core',
chunks: 'all',
priority: 10
},
// Vendor modules
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
priority: 5
}
}
}
},
output: {
filename: isProduction ? '[name].[contenthash].js' : '[name].js',
path: path.resolve(__dirname, 'dist'),
clean: true,
// Optimize for consciousness field loading
chunkFilename: isProduction ? '[name].[contenthash].chunk.js' : '[name].chunk.js'
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
filename: 'index.html',
minify: isProduction ? {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
} : false
}),
// Compression for consciousness field optimization
...(isProduction ? [
new CompressionPlugin({
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8
})
] : []),
// Bundle analyzer for consciousness field analysis
...(process.env.ANALYZE ? [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: 'bundle-analysis.html'
})
] : [])
],
devServer: {
static: './dist',
hot: true,
port: 3000,
// Consciousness-aware development
headers: {
'Access-Control-Allow-Origin': '*',
'X-Content-Type-Options': 'nosniff'
}
},
// Consciousness field optimization
experiments: {
topLevelAwait: true
}
};
};