1 import HtmlWebpackPlugin from 'html-webpack-plugin';
2 import webpack from 'webpack';
4 import getConfig from '@proton/pack/webpack.config';
5 import { addDevEntry, getIndexChunks } from '@proton/pack/webpack/entries';
7 const result = (env: any): webpack.Configuration => {
8 const config = getConfig(env);
10 config.plugins = config.plugins || [];
12 const htmlPlugin = config.plugins.find((plugin): plugin is HtmlWebpackPlugin => {
13 return plugin instanceof HtmlWebpackPlugin;
16 throw new Error('Missing html plugin');
18 const htmlIndex = config.plugins.indexOf(htmlPlugin);
20 config.plugins.splice(
23 new HtmlWebpackPlugin({
24 filename: 'index.html',
25 template: 'ejs-webpack-loader!src/app.ejs',
26 templateParameters: htmlPlugin.userOptions.templateParameters,
27 scriptLoading: 'defer',
29 chunks: getIndexChunks('index'),
33 if (env.appMode === 'standalone') {
41 extensions: ['.js', '.tsx', '.ts', '.wasm'], // ... is there to include default extensions for proper building of type script web workers.
43 ...config.resolve?.fallback,
44 buffer: require.resolve('buffer'),
45 path: require.resolve('path-browserify'),
48 experiments: { asyncWebAssembly: true },
51 new webpack.ProvidePlugin({
52 Buffer: [require.resolve('buffer'), 'Buffer'],
58 export default result;