@genesislcap/webpack-builder 14.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +26 -0
  2. package/cert/localhost.crt +25 -0
  3. package/cert/localhost.key +28 -0
  4. package/dist/cert/localhost.crt +25 -0
  5. package/dist/cert/localhost.key +28 -0
  6. package/dist/config/configFactory.d.ts +7 -0
  7. package/dist/config/configFactory.d.ts.map +1 -0
  8. package/dist/config/configFactory.js +51 -0
  9. package/dist/config/devServers.d.ts +35 -0
  10. package/dist/config/devServers.d.ts.map +1 -0
  11. package/dist/config/devServers.js +67 -0
  12. package/dist/config/postcss.config.d.ts +2 -0
  13. package/dist/config/postcss.config.d.ts.map +1 -0
  14. package/dist/config/postcss.config.js +8 -0
  15. package/dist/config/utils.d.ts +20 -0
  16. package/dist/config/utils.d.ts.map +1 -0
  17. package/dist/config/utils.js +77 -0
  18. package/dist/config/webpack.common.d.ts +68 -0
  19. package/dist/config/webpack.common.d.ts.map +1 -0
  20. package/dist/config/webpack.common.js +113 -0
  21. package/dist/config/webpack.dev.d.ts +68 -0
  22. package/dist/config/webpack.dev.d.ts.map +1 -0
  23. package/dist/config/webpack.dev.js +31 -0
  24. package/dist/config/webpack.prod.d.ts +68 -0
  25. package/dist/config/webpack.prod.d.ts.map +1 -0
  26. package/dist/config/webpack.prod.js +43 -0
  27. package/dist/index.d.ts +4 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +26 -0
  30. package/dist/public/favicon.ico +0 -0
  31. package/dist/public/index.ejs +23 -0
  32. package/dist/public/info.ejs +13 -0
  33. package/dist/public/serve.json +3 -0
  34. package/dist/rules/fileRules.d.ts +17 -0
  35. package/dist/rules/fileRules.d.ts.map +1 -0
  36. package/dist/rules/fileRules.js +24 -0
  37. package/dist/rules/scriptRules.d.ts +14 -0
  38. package/dist/rules/scriptRules.d.ts.map +1 -0
  39. package/dist/rules/scriptRules.js +19 -0
  40. package/dist/rules/styleRules.d.ts +54 -0
  41. package/dist/rules/styleRules.d.ts.map +1 -0
  42. package/dist/rules/styleRules.js +53 -0
  43. package/license.txt +46 -0
  44. package/package.json +56 -0
  45. package/public/cert/README.md +17 -0
  46. package/public/cert/localhost.crt +25 -0
  47. package/public/cert/localhost.key +28 -0
  48. package/public/favicon.ico +0 -0
  49. package/public/index.ejs +23 -0
  50. package/public/info.ejs +13 -0
  51. package/public/serve.json +3 -0
  52. package/src/config/configFactory.js +56 -0
  53. package/src/config/devServers.js +73 -0
  54. package/src/config/postcss.config.js +8 -0
  55. package/src/config/utils.js +99 -0
  56. package/src/config/webpack.common.js +117 -0
  57. package/src/config/webpack.dev.js +32 -0
  58. package/src/config/webpack.prod.js +47 -0
  59. package/src/index.ts +29 -0
  60. package/src/rules/fileRules.js +26 -0
  61. package/src/rules/scriptRules.js +21 -0
  62. package/src/rules/styleRules.js +60 -0
  63. package/tsconfig.json +18 -0
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Webpack builder
2
+
3
+ Builder wrapping [Webpack](https://webpack.js.org/) bundler.
4
+
5
+ # Development SSL Certificates
6
+
7
+ The following files are used by webpack-dev-server when `--https` is set.
8
+
9
+ ```
10
+ localhost.crt
11
+ localhost.key
12
+ ```
13
+
14
+ Please follow the [Development-SSL-Certificate](https://www.notion.so/genesisglobal/Development-SSL-Certificates-30cfd42948674d0db511d04c1adb59db) guide to complete local machine setup.
15
+
16
+ ### Running in HTTPS
17
+
18
+ Passing `--https` to webpack in `development` mode will enable https. Micro frontends and showcase applications will
19
+ likely contain npm scripts to simply this:
20
+
21
+ `"dev:webpack:https": "genx dev -b webpack --https"`
22
+
23
+
24
+ ## License
25
+
26
+ Note: this project provides front end dependencies and uses licensed components listed in the next section, thus licenses for those components are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for more details.
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEKzCCApOgAwIBAgIRAJ2DkMm20N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KXazL7sNlmu4EYt4gOv6S7J2ci0
24
+ YoWYecRKGCnIPB+WyKKrCvQAOdUzOsGGeAlxGVQ3WwKBgE7fJGLuraf1hHRMuPsS
25
+ ZGnJE93QVWOFCym34lxRWEQ3rKEXMtAhUhq/M6x5sJnv7ePTujyDoPAbAioxLS/L
26
+ GsrvcDc91bwNs7sDTyq//n0ehf2HJMFrbdtIPblxA26dHtX7BmW6eppDhm4OV8zO
27
+ 1vSzX8HjCcx1AkcATKDA9J3e
28
+ -----END PRIVATE KEY-----
@@ -0,0 +1,7 @@
1
+ declare function _exports(packageJson: any, mfOptions: {}, customElementTagName: any): {
2
+ port: any;
3
+ default: {};
4
+ isProd: boolean;
5
+ };
6
+ export = _exports;
7
+ //# sourceMappingURL=configFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configFactory.d.ts","sourceRoot":"","sources":["../../src/config/configFactory.js"],"names":[],"mappings":"AAyBiB;;;;EA8BhB"}
@@ -0,0 +1,51 @@
1
+ const { existsSync } = require('node:fs');
2
+ const { resolve } = require('node:path');
3
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
4
+ const portfinderSync = require('portfinder-sync');
5
+ const { merge } = require('webpack-merge');
6
+ const { getWebpackMFConfigFragment, federatedIndexExists } = require('./utils');
7
+ const devConfigFactory = require('./webpack.dev');
8
+ const prodConfig = require('./webpack.prod');
9
+ const getTemplate = () => {
10
+ const templateApp = resolve(process.cwd(), 'public/index.ejs');
11
+ const templateDefault = resolve(__dirname, '../public/index.ejs');
12
+ const template = existsSync(templateApp) ? templateApp : templateDefault;
13
+ console.log(`Using index template: ${template}`);
14
+ return template;
15
+ };
16
+ /**
17
+ * Webpack config factory
18
+ *
19
+ * @param packageJson The package.json file of the target package.
20
+ * @param mfOptions Module federation options to merged into the base options
21
+ * @param customElementTagName Tag name for insertion in the index.html file, ie. `foundation-xyz`
22
+ * @returns The the port number, webpack config (which can be extended further), and an isProd flag.
23
+ */
24
+ module.exports = (packageJson, mfOptions = {}, customElementTagName) => {
25
+ var _a;
26
+ const port = portfinderSync.getPort(((_a = packageJson.config) === null || _a === void 0 ? void 0 : _a.PORT) || process.env.PORT || 9000);
27
+ const isProd = process.env.NODE_ENV === 'production';
28
+ const envConfig = isProd ? prodConfig() : devConfigFactory(port);
29
+ const federatedIndexPresent = federatedIndexExists();
30
+ const mfConfig = federatedIndexPresent
31
+ ? getWebpackMFConfigFragment(packageJson, mfOptions, customElementTagName ? 'info.html' : 'index.html')
32
+ : {};
33
+ const mergedConfig = merge(envConfig, mfConfig, {
34
+ plugins: [
35
+ ...(customElementTagName || !federatedIndexPresent
36
+ ? [
37
+ new HtmlWebpackPlugin({
38
+ title: `${packageJson.description}`,
39
+ template: getTemplate(),
40
+ customElementTagName,
41
+ }),
42
+ ]
43
+ : []),
44
+ ],
45
+ });
46
+ return {
47
+ port,
48
+ default: mergedConfig,
49
+ isProd,
50
+ };
51
+ };
@@ -0,0 +1,35 @@
1
+ export namespace devServers {
2
+ function _default(port?: string | number, host?: string): {
3
+ open: boolean;
4
+ historyApiFallback: boolean;
5
+ allowedHosts: string;
6
+ host: string;
7
+ port: string | number;
8
+ server: {
9
+ type: string;
10
+ };
11
+ client: {
12
+ overlay: {
13
+ runtimeErrors: boolean;
14
+ };
15
+ };
16
+ proxy: {
17
+ context: string[];
18
+ target: string;
19
+ secure: boolean;
20
+ changeOrigin: boolean;
21
+ }[];
22
+ headers: {
23
+ 'Access-Control-Allow-Origin': string;
24
+ 'Access-Control-Allow-Methods': string;
25
+ 'Access-Control-Allow-Headers': string;
26
+ };
27
+ static: {
28
+ directory: string;
29
+ publicPath: string;
30
+ watch: boolean;
31
+ }[];
32
+ };
33
+ export { _default as default };
34
+ }
35
+ //# sourceMappingURL=devServers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devServers.d.ts","sourceRoot":"","sources":["../../src/config/devServers.js"],"names":[],"mappings":";IA2BW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwCR"}
@@ -0,0 +1,67 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const server = {
4
+ type: process.argv.includes('--https') ? 'https' : 'http',
5
+ };
6
+ if (server.type === 'https') {
7
+ try {
8
+ server.options = {
9
+ cert: fs.readFileSync(path.resolve(__dirname, '../cert/localhost.crt')),
10
+ key: fs.readFileSync(path.resolve(__dirname, '../cert/localhost.key')),
11
+ };
12
+ }
13
+ catch (err) {
14
+ console.warn('You may be trying to run the webpack dev server in HTTPS mode without local certificates. Please see @genesislcap/webpack-builder README');
15
+ }
16
+ }
17
+ const convertWsEndpointToHTTP = (endpoint = '', socketExt) => (endpoint.startsWith('ws:')
18
+ ? endpoint.replace('ws:', 'http:')
19
+ : endpoint.startsWith('wss:')
20
+ ? endpoint.replace('wss:', 'https:')
21
+ : endpoint).replace(`/${socketExt}`, '');
22
+ const devServers = {
23
+ default: (port = process.env.PORT || 9000, host = 'localhost') => {
24
+ const socketExt = process.env.SOCKET_EXT || 'gwf';
25
+ const target = convertWsEndpointToHTTP(process.env.API_HOST, socketExt);
26
+ return {
27
+ open: !process.env.CI,
28
+ historyApiFallback: true,
29
+ allowedHosts: 'all',
30
+ host,
31
+ port,
32
+ server,
33
+ client: {
34
+ overlay: {
35
+ runtimeErrors: false,
36
+ },
37
+ },
38
+ proxy: [
39
+ {
40
+ context: [`/${socketExt}/**`, '/sso/**'],
41
+ target,
42
+ secure: false,
43
+ changeOrigin: true,
44
+ },
45
+ ],
46
+ // disableHostCheck: true,
47
+ // sockHost: 'localhost',
48
+ // sockPort: '8080',
49
+ // https: true,
50
+ headers: {
51
+ 'Access-Control-Allow-Origin': '*',
52
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
53
+ 'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
54
+ },
55
+ static: [
56
+ {
57
+ directory: path.resolve(process.cwd(), './public'),
58
+ publicPath: '/',
59
+ watch: true,
60
+ },
61
+ ],
62
+ };
63
+ },
64
+ };
65
+ module.exports = {
66
+ devServers,
67
+ };
@@ -0,0 +1,2 @@
1
+ export const plugins: any[];
2
+ //# sourceMappingURL=postcss.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcss.config.d.ts","sourceRoot":"","sources":["../../src/config/postcss.config.js"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ plugins: [
3
+ require('postcss-import'),
4
+ require('postcss-preset-env')({
5
+ browsers: 'last 2 versions',
6
+ }),
7
+ ],
8
+ };
@@ -0,0 +1,20 @@
1
+ export function getFederatedPkgName(pkgName: any): any;
2
+ /**
3
+ * TODO: Add prod version logic
4
+ */
5
+ export function getRemoteEntryUrl(port: any, host?: string): string;
6
+ export function getRemoteEntry(name: any, port: any, host?: string): string;
7
+ /**
8
+ * Webpack module federation config fragment factory
9
+ *
10
+ * @param packageJson The package.json file of the target package.
11
+ * @param mfOptions Module federation options to merged into the base options
12
+ * @param htmlFilename The filename value for the report generated by the html plugin
13
+ * @returns A partial webpack config fragment to be merged into a final webpack config.
14
+ */
15
+ export function getWebpackMFConfigFragment(packageJson: any, mfOptions?: {}, htmlFilename?: string): {
16
+ entry: string;
17
+ plugins: any[];
18
+ };
19
+ export function federatedIndexExists(): boolean;
20
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/config/utils.js"],"names":[],"mappings":"AAUA,uDAMC;AAED;;GAEG;AACH,oEACiD;AACjD,4EAC4C;AAW5C;;;;;;;GAOG;AACH;;;EA+CC;AA5DD,gDAGC"}
@@ -0,0 +1,77 @@
1
+ const { existsSync } = require('node:fs');
2
+ const { resolve } = require('node:path');
3
+ const DashboardPlugin = require('@module-federation/dashboard-plugin');
4
+ const { camelCase } = require('camel-case');
5
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
6
+ const webpack = require('webpack');
7
+ const { ModuleFederationPlugin } = webpack.container;
8
+ const remoteEntryFilename = 'remoteEntry.js';
9
+ const getFederatedPkgName = (pkgName) => {
10
+ try {
11
+ return camelCase(pkgName.split('/').pop());
12
+ }
13
+ catch (e) {
14
+ return pkgName;
15
+ }
16
+ };
17
+ /**
18
+ * TODO: Add prod version logic
19
+ */
20
+ const getRemoteEntryUrl = (port, host = 'localhost') => `http://${host}:${port}/${remoteEntryFilename}`;
21
+ const getRemoteEntry = (name, port, host = 'localhost') => `${name}@${getRemoteEntryUrl(port, host)}`;
22
+ const federatedIndex = './src/index.federated.ts';
23
+ const resolveFederatedIndex = () => resolve(process.cwd(), federatedIndex);
24
+ const federatedIndexExists = () => {
25
+ const federatedIndexPath = resolveFederatedIndex();
26
+ return existsSync(federatedIndexPath);
27
+ };
28
+ /**
29
+ * Webpack module federation config fragment factory
30
+ *
31
+ * @param packageJson The package.json file of the target package.
32
+ * @param mfOptions Module federation options to merged into the base options
33
+ * @param htmlFilename The filename value for the report generated by the html plugin
34
+ * @returns A partial webpack config fragment to be merged into a final webpack config.
35
+ */
36
+ const getWebpackMFConfigFragment = (packageJson, mfOptions = {}, htmlFilename = 'index.html') => {
37
+ const name = getFederatedPkgName(packageJson.name);
38
+ const deps = packageJson.dependencies;
39
+ const { exposes: mfExposes = {}, remotes: mfRemotes = {}, shared: mfShared = {} } = mfOptions;
40
+ const exposes = Object.assign({ './index': federatedIndex }, mfExposes);
41
+ const remotes = Object.assign({}, mfRemotes);
42
+ const shared = Object.assign(Object.assign({}, deps), mfShared);
43
+ const moduleFederationOptions = {
44
+ name,
45
+ filename: remoteEntryFilename,
46
+ remotes,
47
+ exposes,
48
+ shared,
49
+ };
50
+ return {
51
+ entry: resolveFederatedIndex(),
52
+ plugins: [
53
+ new ModuleFederationPlugin(moduleFederationOptions),
54
+ new DashboardPlugin({
55
+ dashboardURL: 'http://localhost:3000/api/update',
56
+ publishVersion: '1.0.0',
57
+ }),
58
+ new HtmlWebpackPlugin({
59
+ title: `${packageJson.description} (Federated)`,
60
+ template: resolve(__dirname, '../public/info.ejs'),
61
+ filename: htmlFilename,
62
+ inject: false,
63
+ /**
64
+ * Passing arbitrary data to the template for display
65
+ */
66
+ moduleFederationDetails: JSON.stringify(moduleFederationOptions, undefined, 2),
67
+ }),
68
+ ],
69
+ };
70
+ };
71
+ module.exports = {
72
+ getFederatedPkgName,
73
+ getRemoteEntryUrl,
74
+ getRemoteEntry,
75
+ getWebpackMFConfigFragment,
76
+ federatedIndexExists,
77
+ };
@@ -0,0 +1,68 @@
1
+ declare function _exports(): {
2
+ entry: string;
3
+ plugins: any[];
4
+ output: {
5
+ strictModuleErrorHandling: boolean;
6
+ strictModuleExceptionHandling: boolean;
7
+ path: string;
8
+ publicPath: string;
9
+ };
10
+ resolve: {
11
+ extensions: string[];
12
+ modules: string[];
13
+ };
14
+ module: {
15
+ rules: ({
16
+ test: RegExp;
17
+ type: string;
18
+ } | {
19
+ test: RegExp;
20
+ use: {
21
+ loader: string;
22
+ }[];
23
+ } | {
24
+ test: RegExp;
25
+ include: RegExp[];
26
+ use: (string | {
27
+ loader: string;
28
+ options: {
29
+ importLoaders: number;
30
+ };
31
+ } | {
32
+ loader: string;
33
+ options: {
34
+ postcssOptions: {
35
+ config: string;
36
+ };
37
+ };
38
+ })[];
39
+ } | {
40
+ test: RegExp;
41
+ exclude: RegExp[];
42
+ use: (string | {
43
+ loader: string;
44
+ options: {
45
+ importLoaders: number;
46
+ };
47
+ } | {
48
+ loader: string;
49
+ options: {
50
+ postcssOptions: {
51
+ config: string;
52
+ };
53
+ };
54
+ })[];
55
+ })[];
56
+ };
57
+ experiments: {
58
+ topLevelAwait: boolean;
59
+ lazyCompilation: boolean;
60
+ };
61
+ performance: {
62
+ hints: boolean;
63
+ maxEntrypointSize: number;
64
+ maxAssetSize: number;
65
+ };
66
+ };
67
+ export = _exports;
68
+ //# sourceMappingURL=webpack.common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.common.d.ts","sourceRoot":"","sources":["../../src/config/webpack.common.js"],"names":[],"mappings":"AA0CiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Ef"}
@@ -0,0 +1,113 @@
1
+ const crypto = require('crypto');
2
+ const path = require('path');
3
+ const CopyPlugin = require('copy-webpack-plugin');
4
+ const fs = require('fs-extra');
5
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
+ const { DefinePlugin, ProgressPlugin } = require('webpack');
7
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
8
+ const { appFileRules } = require('../rules/fileRules');
9
+ const { appScriptRules } = require('../rules/scriptRules');
10
+ const { appStyleRules } = require('../rules/styleRules');
11
+ // Avoid MD4 hash for OpenSSL 3 compatibility
12
+ // https://github.com/cockpit-project/starter-kit/commit/3220617fec508aabbbc226a87a165c21fb72e913
13
+ // Using Webpack v5.54.0+ and output.hashFunction = "xxhash64" should make this unnecessary, however
14
+ // builds still fail with an OpenSSL error in practice
15
+ const cryptoOrigCreateHash = crypto.createHash;
16
+ crypto.createHash = (algorithm) => cryptoOrigCreateHash(algorithm == 'md4' ? 'sha256' : algorithm);
17
+ const readFile = (filePath) => {
18
+ if (!filePath)
19
+ return '';
20
+ const configPath = path.resolve(process.cwd(), filePath);
21
+ try {
22
+ return fs.readFileSync(configPath, 'utf8');
23
+ }
24
+ catch (e) {
25
+ console.error(e);
26
+ return '';
27
+ }
28
+ };
29
+ /**
30
+ * Switching the '/' instead of 'auto', as webpack and perhaps the html-webpack-plugin seem to get confused over
31
+ * mime types, and this can block deep linking. Reading through the 'Practical Module Federation' guide, we may need
32
+ * to revisit this, dev v prod, resolving remotes.
33
+ */
34
+ const publicPath = typeof process.env.PUBLIC_PATH !== 'undefined' ? process.env.PUBLIC_PATH : '/';
35
+ /**
36
+ * Webpack common config factory used as a baseline across both production and development builds.
37
+ * Used mainly in conjunction with ./configFactory.js, but there are a few standalone consumers in foundation-ui.
38
+ *
39
+ * @returns A common webpack config.
40
+ */
41
+ module.exports = () => ({
42
+ entry: path.resolve(process.cwd(), './src/index.ts'),
43
+ plugins: [
44
+ new CopyPlugin({
45
+ patterns: [
46
+ {
47
+ from: path.resolve(__dirname, '../public'),
48
+ },
49
+ ],
50
+ }),
51
+ /**
52
+ * TODO: Test making this dynamic using .env files and the DotEnv Webpack plugin.
53
+ */
54
+ new DefinePlugin({
55
+ API_HOST: JSON.stringify(process.env.API_HOST),
56
+ DEFAULT_ORGANISATION: JSON.stringify(process.env.DEFAULT_ORGANISATION),
57
+ DEFAULT_USER: JSON.stringify(process.env.DEFAULT_USER),
58
+ DEFAULT_PASSWORD: JSON.stringify(process.env.DEFAULT_PASSWORD),
59
+ NODE_ENV: JSON.stringify(process.env.NODE_ENV),
60
+ FORCE_HTTP: JSON.stringify(process.env.FORCE_HTTP),
61
+ HTTP_CONFIG: JSON.stringify(readFile(process.env.HTTP_CONFIG_PATH)),
62
+ SOCKET_EXT: JSON.stringify(process.env.SOCKET_EXT),
63
+ }),
64
+ new ProgressPlugin(),
65
+ new MiniCssExtractPlugin(),
66
+ /**
67
+ * Run via 'build:webpack:stats'.
68
+ */
69
+ ...(process.env.ANALYZE
70
+ ? [
71
+ new BundleAnalyzerPlugin({
72
+ reportTitle: `Webpack Visualizer`,
73
+ reportFilename: path.join(process.cwd(), './dist', 'webpack.stats.html'),
74
+ analyzerMode: 'static',
75
+ openAnalyzer: false,
76
+ }),
77
+ ]
78
+ : []),
79
+ ],
80
+ output: {
81
+ strictModuleErrorHandling: true,
82
+ strictModuleExceptionHandling: true,
83
+ path: path.resolve(process.cwd(), './dist'),
84
+ publicPath,
85
+ },
86
+ resolve: {
87
+ extensions: ['.ts', '.js'],
88
+ modules: ['node_modules'],
89
+ },
90
+ module: {
91
+ rules: [
92
+ appScriptRules.typescript(),
93
+ // Files
94
+ appFileRules.fonts(),
95
+ appFileRules.html(),
96
+ appFileRules.images(),
97
+ // Styles
98
+ appStyleRules.headCss(),
99
+ appStyleRules.css(),
100
+ appStyleRules.sass(),
101
+ ],
102
+ },
103
+ experiments: {
104
+ topLevelAwait: true,
105
+ lazyCompilation: false,
106
+ // outputModule: true,
107
+ },
108
+ performance: {
109
+ hints: false,
110
+ maxEntrypointSize: 512000,
111
+ maxAssetSize: 512000,
112
+ },
113
+ });