webpack update + loading prod files

This commit is contained in:
Elio Struyf
2024-09-19 12:57:39 +02:00
parent 0110b7365c
commit b9508df4f8
10 changed files with 167 additions and 57 deletions

View File

@@ -1,5 +1,3 @@
//@ts-check
'use strict';
const path = require('path');
@@ -7,13 +5,15 @@ const {
ProvidePlugin
} = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const WebpackManifestPlugin = require('webpack-manifest-plugin').WebpackManifestPlugin;
const config = [{
name: 'dashboard',
target: 'web',
entry: './src/dashboardWebView/index.tsx',
output: {
filename: 'dashboardWebView.js',
filename: 'dashboard.[name].js',
chunkFilename: '[name].[contenthash].js',
path: path.resolve(__dirname, '../dist')
},
devtool: 'source-map',
@@ -81,6 +81,17 @@ module.exports = (env, argv) => {
reportFilename: "dashboard.html",
openAnalyzer: false
}));
configItem.plugins.push(new WebpackManifestPlugin({
publicPath: "",
fileName: "dashboard.manifest.json"
}));
configItem.optimization = {
splitChunks: {
chunks: 'all',
},
};
}
}

View File

@@ -1,22 +1,22 @@
//@ts-check
'use strict';
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const WebpackManifestPlugin = require('webpack-manifest-plugin').WebpackManifestPlugin;
const config = [{
name: 'panel',
target: 'web',
entry: './src/panelWebView/index.tsx',
output: {
filename: 'panelWebView.js',
filename: 'panel.[name].js',
chunkFilename: '[name].[contenthash].js',
path: path.resolve(__dirname, '../dist')
},
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js', '.tsx', '.jsx'],
fallback: {
fallback: {
"path": require.resolve("path-browserify")
}
},
@@ -73,7 +73,7 @@ const config = [{
if (error.message === "ResizeObserver loop limit exceeded") {
return false;
}
return true;
}
}
@@ -87,12 +87,23 @@ module.exports = (env, argv) => {
if (argv.mode === 'production') {
configItem.devtool = "hidden-source-map";
configItem.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: "viewpanel.html",
openAnalyzer: false
}));
configItem.plugins.push(new WebpackManifestPlugin({
publicPath: "",
fileName: "panel.manifest.json"
}));
configItem.optimization = {
splitChunks: {
chunks: 'all',
},
};
}
}