forked from mmomtchev/sqlite-wasm-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.cjs
More file actions
74 lines (72 loc) · 1.93 KB
/
webpack.config.cjs
File metadata and controls
74 lines (72 loc) · 1.93 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
const path = require('path');
const webpack = require('webpack');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const PreloadWebpackPlugin = require('@vue/preload-webpack-plugin');
const StatoscopeWebpackPlugin = require('@statoscope/webpack-plugin').default;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = (env, argv) => {
let profiler = [];
switch (env.profiler) {
case 'statoscope':
profiler = [new StatoscopeWebpackPlugin()];
break;
case 'treemap':
profiler = [new BundleAnalyzerPlugin()];
break;
}
return {
entry: './examples/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
}
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
plugins: [
new TsconfigPathsPlugin({ configFile: './examples/tsconfig.json' }),
],
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'docs', 'examples'),
clean: true
},
plugins: [
new HtmlWebpackPlugin({
template: 'examples/index.html'
}),
new PreloadWebpackPlugin(),
new webpack.DefinePlugin({
SQLITE_DEBUG: JSON.stringify(process.env.SQLITE_DEBUG?.split(',') ?? [])
}),
...profiler
],
optimization: {
splitChunks: {
chunks: 'all'
},
},
stats: 'detailed',
devtool: argv.mode === 'production' ? 'source-map' : 'inline-source-map',
devServer: {
static: {
directory: path.join(__dirname, 'examples'),
},
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp'
},
compress: true,
port: 9000,
}
};
};