This is the webpack config I tried last with just disabling the chunks all together.
My webpack versions are:
"webpack": "^5.82.1",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.15.0",
"webpack-merge": "^5.8.0"
import path from 'path';
import { fileURLToPath } from 'url';
// eslint-disable-next-line
import CopyPlugin from 'copy-webpack-plugin';
import webpack from 'webpack';
import scopeUIPlugin from './postcss/postcss-scope-ui.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default env => {
var external_values = [
{
oimo: true,
earcut: true,
cannon: true,
},
];
// If --env=BABYLON=true is not found then ignore packing babylon
if (env.BABYLON === undefined) {
external_values.push(/^@babylonjs.*$/);
}
return {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.esm.json',
},
},
],
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'esbuild-loader',
options: {
target: 'ES2022',
},
},
{
test: /\.css$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: 'viewer__[local]',
},
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['@tailwindcss/postcss', scopeUIPlugin],
},
},
},
],
},
{
test: /\.(gif|svg|jpe?g|png|eot|woff|woff2|ttf)$/,
type: 'asset/inline',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new CopyPlugin({
patterns: [
{
from: 'glsl/*.fx',
to: path.resolve(__dirname, 'dist'),
},
],
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
externals: external_values,
performance: {
maxEntrypointSize: 2000000,
maxAssetSize: 2000000,
},
output: {
path: path.resolve(__dirname, 'dist/lib/esm'),
filename: 'viewer.bundle.js',
library: {
type: 'module',
},
clean: true,
},
experiments: {
outputModule: true,
},
devtool: 'source-map',
devServer: {
static: {
directory: './samples',
},
devMiddleware: {
publicPath: '/dist/',
},
open: true,
},
};
};