@genesislcap/webpack-builder 14.26.8-alpha-64bb9e2.0 → 14.27.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.
- package/dist/commands/build.d.ts +3 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +22 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +10 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/config/devServer.d.ts +4 -0
- package/dist/config/devServer.d.ts.map +1 -0
- package/dist/config/devServer.js +75 -0
- package/dist/config/entry.d.ts +4 -0
- package/dist/config/entry.d.ts.map +1 -0
- package/dist/config/entry.js +19 -0
- package/dist/config/federation.d.ts +15 -0
- package/dist/config/federation.d.ts.map +1 -0
- package/dist/config/federation.js +69 -0
- package/dist/config/getConfig.d.ts +9 -0
- package/dist/config/getConfig.d.ts.map +1 -0
- package/dist/config/getConfig.js +46 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/module.d.ts +4 -0
- package/dist/config/module.d.ts.map +1 -0
- package/dist/config/module.js +20 -0
- package/dist/config/optimization.d.ts +4 -0
- package/dist/config/optimization.d.ts.map +1 -0
- package/dist/config/optimization.js +39 -0
- package/dist/config/output.d.ts +4 -0
- package/dist/config/output.d.ts.map +1 -0
- package/dist/config/output.js +34 -0
- package/dist/config/plugins.d.ts +4 -0
- package/dist/config/plugins.d.ts.map +1 -0
- package/dist/config/plugins.js +79 -0
- package/dist/config/resolveLoader.d.ts +4 -0
- package/dist/config/resolveLoader.d.ts.map +1 -0
- package/dist/config/resolveLoader.js +18 -0
- package/dist/{rules → config/rules}/fileRules.d.ts +5 -5
- package/dist/config/rules/fileRules.d.ts.map +1 -0
- package/dist/{rules → config/rules}/fileRules.js +4 -4
- package/dist/{rules → config/rules}/scriptRules.d.ts +3 -4
- package/dist/config/rules/scriptRules.d.ts.map +1 -0
- package/dist/{rules → config/rules}/scriptRules.js +4 -6
- package/dist/{rules → config/rules}/styleRules.d.ts +10 -23
- package/dist/config/rules/styleRules.d.ts.map +1 -0
- package/dist/config/rules/styleRules.js +38 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/utils/fs.d.ts +2 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +18 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/package.json +5 -4
- package/src/commands/build.ts +24 -0
- package/src/commands/dev.ts +7 -0
- package/src/commands/index.ts +2 -0
- package/src/config/devServer.ts +88 -0
- package/src/config/entry.ts +24 -0
- package/src/config/federation.ts +91 -0
- package/src/config/getConfig.ts +49 -0
- package/src/config/index.ts +1 -0
- package/src/config/module.ts +21 -0
- package/src/config/optimization.ts +45 -0
- package/src/config/output.ts +42 -0
- package/src/config/plugins.ts +95 -0
- package/src/config/resolveLoader.ts +19 -0
- package/src/{rules/fileRules.js → config/rules/fileRules.ts} +1 -5
- package/src/{rules/scriptRules.js → config/rules/scriptRules.ts} +1 -8
- package/src/config/rules/styleRules.ts +38 -0
- package/src/index.ts +10 -9
- package/src/utils/fs.ts +13 -0
- package/src/utils/index.ts +1 -0
- package/dist/config/configFactory.d.ts +0 -7
- package/dist/config/configFactory.d.ts.map +0 -1
- package/dist/config/configFactory.js +0 -51
- package/dist/config/devServers.d.ts +0 -35
- package/dist/config/devServers.d.ts.map +0 -1
- package/dist/config/devServers.js +0 -67
- package/dist/config/postcss.config.d.ts +0 -2
- package/dist/config/postcss.config.d.ts.map +0 -1
- package/dist/config/postcss.config.js +0 -8
- package/dist/config/utils.d.ts +0 -20
- package/dist/config/utils.d.ts.map +0 -1
- package/dist/config/utils.js +0 -77
- package/dist/config/webpack.common.d.ts +0 -68
- package/dist/config/webpack.common.d.ts.map +0 -1
- package/dist/config/webpack.common.js +0 -106
- package/dist/config/webpack.dev.d.ts +0 -68
- package/dist/config/webpack.dev.d.ts.map +0 -1
- package/dist/config/webpack.dev.js +0 -31
- package/dist/config/webpack.prod.d.ts +0 -68
- package/dist/config/webpack.prod.d.ts.map +0 -1
- package/dist/config/webpack.prod.js +0 -43
- package/dist/rules/fileRules.d.ts.map +0 -1
- package/dist/rules/scriptRules.d.ts.map +0 -1
- package/dist/rules/styleRules.d.ts.map +0 -1
- package/dist/rules/styleRules.js +0 -53
- package/public/cert/README.md +0 -17
- package/public/cert/localhost.crt +0 -25
- package/public/cert/localhost.key +0 -28
- package/src/config/configFactory.js +0 -56
- package/src/config/devServers.js +0 -73
- package/src/config/postcss.config.js +0 -8
- package/src/config/utils.js +0 -99
- package/src/config/webpack.common.js +0 -109
- package/src/config/webpack.dev.js +0 -32
- package/src/config/webpack.prod.js +0 -47
- package/src/rules/styleRules.js +0 -60
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { resolve, join } from 'node:path';
|
|
3
|
+
import type { BuildContext } from '@genesislcap/build-kit';
|
|
4
|
+
import { objToSnakeCase } from '@genesislcap/build-kit';
|
|
5
|
+
import CopyPlugin from 'copy-webpack-plugin';
|
|
6
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
7
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
8
|
+
import type { Configuration } from 'webpack';
|
|
9
|
+
import { DefinePlugin } from 'webpack';
|
|
10
|
+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
11
|
+
import WebpackPwaManifest from 'webpack-pwa-manifest';
|
|
12
|
+
import WebpackBar from 'webpackbar';
|
|
13
|
+
import { InjectManifest } from 'workbox-webpack-plugin';
|
|
14
|
+
import { readFile } from '../utils';
|
|
15
|
+
import { getFederationPlugins, federatedIndexExists, resolveFederationOptions } from './federation';
|
|
16
|
+
|
|
17
|
+
const getTemplate = (cwd) => {
|
|
18
|
+
const templateApp = resolve(cwd, 'public/index.ejs');
|
|
19
|
+
const templateDefault = resolve(__dirname, '../public/index.ejs');
|
|
20
|
+
const template = existsSync(templateApp) ? templateApp : templateDefault;
|
|
21
|
+
console.log(`Using index template: ${template}`);
|
|
22
|
+
return template;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const plugins = (ctx: BuildContext): Configuration['plugins'] => {
|
|
26
|
+
const {
|
|
27
|
+
cli: { isAnalyze },
|
|
28
|
+
dirs: { cwd },
|
|
29
|
+
config: {
|
|
30
|
+
serviceWorker,
|
|
31
|
+
pwa,
|
|
32
|
+
federation,
|
|
33
|
+
app: { rootElement },
|
|
34
|
+
},
|
|
35
|
+
pkg,
|
|
36
|
+
} = ctx;
|
|
37
|
+
|
|
38
|
+
const federatedIndexPresent = federatedIndexExists();
|
|
39
|
+
const moduleFederationOptions = resolveFederationOptions(federation, pkg);
|
|
40
|
+
|
|
41
|
+
return [
|
|
42
|
+
new CopyPlugin({
|
|
43
|
+
patterns: [
|
|
44
|
+
{
|
|
45
|
+
from: resolve(__dirname, '../../public'),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
49
|
+
new DefinePlugin({
|
|
50
|
+
API_HOST: JSON.stringify(process.env.API_HOST),
|
|
51
|
+
DEFAULT_ORGANISATION: JSON.stringify(process.env.DEFAULT_ORGANISATION),
|
|
52
|
+
DEFAULT_USER: JSON.stringify(process.env.DEFAULT_USER),
|
|
53
|
+
DEFAULT_PASSWORD: JSON.stringify(process.env.DEFAULT_PASSWORD),
|
|
54
|
+
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
|
|
55
|
+
FORCE_HTTP: JSON.stringify(process.env.FORCE_HTTP),
|
|
56
|
+
HTTP_CONFIG: JSON.stringify(readFile(process.env.HTTP_CONFIG_PATH)),
|
|
57
|
+
SOCKET_EXT: JSON.stringify(process.env.SOCKET_EXT),
|
|
58
|
+
}),
|
|
59
|
+
new WebpackBar(),
|
|
60
|
+
new MiniCssExtractPlugin(),
|
|
61
|
+
(rootElement || !federatedIndexPresent) &&
|
|
62
|
+
new HtmlWebpackPlugin({
|
|
63
|
+
title: `${pkg.description}`,
|
|
64
|
+
template: getTemplate(cwd),
|
|
65
|
+
customElementTagName: rootElement,
|
|
66
|
+
minify: false,
|
|
67
|
+
}),
|
|
68
|
+
...getFederationPlugins(federatedIndexPresent, rootElement, moduleFederationOptions, pkg),
|
|
69
|
+
isAnalyze &&
|
|
70
|
+
new BundleAnalyzerPlugin({
|
|
71
|
+
reportTitle: `Webpack Visualizer`,
|
|
72
|
+
reportFilename: join(cwd, './dist', 'webpack.stats.html'),
|
|
73
|
+
analyzerMode: 'static',
|
|
74
|
+
openAnalyzer: false,
|
|
75
|
+
}),
|
|
76
|
+
pwa &&
|
|
77
|
+
new WebpackPwaManifest({
|
|
78
|
+
...objToSnakeCase(pwa),
|
|
79
|
+
name: pwa.name,
|
|
80
|
+
icons:
|
|
81
|
+
Array.isArray(pwa.icons) &&
|
|
82
|
+
pwa.icons.map((icon) => ({
|
|
83
|
+
sizes: icon.sizes,
|
|
84
|
+
src: resolve(cwd, icon.src),
|
|
85
|
+
})),
|
|
86
|
+
}),
|
|
87
|
+
serviceWorker &&
|
|
88
|
+
new InjectManifest({
|
|
89
|
+
swSrc: './src/' + serviceWorker.worker,
|
|
90
|
+
swDest: serviceWorker.assetName,
|
|
91
|
+
exclude: serviceWorker.exclude,
|
|
92
|
+
maximumFileSizeToCacheInBytes: serviceWorker.maximumFileSizeToCache,
|
|
93
|
+
}),
|
|
94
|
+
].filter(Boolean);
|
|
95
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import type { BuildContext } from '@genesislcap/build-kit';
|
|
3
|
+
import type { Configuration } from 'webpack';
|
|
4
|
+
|
|
5
|
+
export const resolveLoader = (ctx: BuildContext): Configuration['resolveLoader'] => {
|
|
6
|
+
const {
|
|
7
|
+
dirs: { cwd, workspace },
|
|
8
|
+
} = ctx;
|
|
9
|
+
return {
|
|
10
|
+
modules: [
|
|
11
|
+
// webpack-builder node_modules
|
|
12
|
+
resolve(__dirname, '../../node_modules'),
|
|
13
|
+
// workspace folder node_modules (if set)
|
|
14
|
+
workspace ? resolve(workspace, 'node_modules') : '',
|
|
15
|
+
// package node_modules
|
|
16
|
+
resolve(cwd, 'node_modules'),
|
|
17
|
+
].filter(Boolean),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// In this config named capturing isn't desired.
|
|
3
3
|
// May cause adverse affects with webpack.
|
|
4
4
|
|
|
5
|
-
const appFileRules = {
|
|
5
|
+
export const appFileRules = {
|
|
6
6
|
fonts: () => ({
|
|
7
7
|
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
8
8
|
type: 'asset/resource',
|
|
@@ -20,7 +20,3 @@ const appFileRules = {
|
|
|
20
20
|
type: 'asset/resource',
|
|
21
21
|
}),
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
appFileRules,
|
|
26
|
-
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const appScriptRules = {
|
|
1
|
+
export const appScriptRules = {
|
|
4
2
|
typescript: () => ({
|
|
5
3
|
test: /\.ts$/i,
|
|
6
4
|
exclude: /node_modules/,
|
|
@@ -8,14 +6,9 @@ const appScriptRules = {
|
|
|
8
6
|
{
|
|
9
7
|
loader: 'ts-loader',
|
|
10
8
|
options: {
|
|
11
|
-
configFile: path.resolve(process.cwd(), './tsconfig.json'),
|
|
12
9
|
projectReferences: true,
|
|
13
10
|
},
|
|
14
11
|
},
|
|
15
12
|
],
|
|
16
13
|
}),
|
|
17
14
|
};
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
appScriptRules,
|
|
21
|
-
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const cssLoader = (importLoaders = 1, useHash = true) => ({
|
|
2
|
+
loader: 'css-loader',
|
|
3
|
+
options: {
|
|
4
|
+
importLoaders,
|
|
5
|
+
},
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const postCSSLoader = () => ({
|
|
9
|
+
loader: 'postcss-loader',
|
|
10
|
+
options: {
|
|
11
|
+
postcssOptions: {
|
|
12
|
+
plugins: [
|
|
13
|
+
'postcss-import',
|
|
14
|
+
[
|
|
15
|
+
'postcss-preset-env',
|
|
16
|
+
{
|
|
17
|
+
browsers: 'last 2 versions',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const headCssPatterns = [/main\.css$/i, /head\.css$/i, /index\.css$/i];
|
|
26
|
+
|
|
27
|
+
export const appStyleRules = {
|
|
28
|
+
headCss: () => ({
|
|
29
|
+
test: /\.css$/i,
|
|
30
|
+
include: headCssPatterns,
|
|
31
|
+
use: ['style-loader', cssLoader(), postCSSLoader()],
|
|
32
|
+
}),
|
|
33
|
+
css: (useHash = true) => ({
|
|
34
|
+
test: /\.css$/i,
|
|
35
|
+
exclude: [...headCssPatterns],
|
|
36
|
+
use: [cssLoader(), postCSSLoader()],
|
|
37
|
+
}),
|
|
38
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { run, resolveBin } from '@genesislcap/build-kit';
|
|
2
2
|
import type { BuildContext } from '@genesislcap/build-kit';
|
|
3
|
+
import webpack from 'webpack';
|
|
4
|
+
import { build, dev } from './commands';
|
|
5
|
+
import { getConfig } from './config';
|
|
3
6
|
|
|
4
7
|
export default async (ctx: BuildContext) => {
|
|
5
8
|
const {
|
|
@@ -13,16 +16,14 @@ export default async (ctx: BuildContext) => {
|
|
|
13
16
|
run(cwd, `${mftCLI}`);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
const webpack = await resolveBin('webpack');
|
|
17
|
-
|
|
18
19
|
if (isDev) {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
} else if (isAnalyze) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const config = getConfig(ctx);
|
|
21
|
+
const compiler = webpack(config);
|
|
22
|
+
dev(compiler, config);
|
|
23
|
+
} else if (isBuild || isAnalyze) {
|
|
24
|
+
const config = getConfig(ctx);
|
|
25
|
+
const compiler = webpack(config);
|
|
26
|
+
await build(compiler);
|
|
26
27
|
} else {
|
|
27
28
|
throw new Error(`Unrecognised command: ${JSON.stringify(options)}`);
|
|
28
29
|
}
|
package/src/utils/fs.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export const readFile = (filePath) => {
|
|
5
|
+
if (!filePath) return '';
|
|
6
|
+
const resolvedPath = resolve(process.cwd(), filePath);
|
|
7
|
+
try {
|
|
8
|
+
return readFileSync(resolvedPath, 'utf8');
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error(e);
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './fs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configFactory.d.ts","sourceRoot":"","sources":["../../src/config/configFactory.js"],"names":[],"mappings":"AAyBiB;;;;EA8BhB"}
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"devServers.d.ts","sourceRoot":"","sources":["../../src/config/devServers.js"],"names":[],"mappings":";IA2BW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwCR"}
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postcss.config.d.ts","sourceRoot":"","sources":["../../src/config/postcss.config.js"],"names":[],"mappings":""}
|
package/dist/config/utils.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/config/utils.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.common.d.ts","sourceRoot":"","sources":["../../src/config/webpack.common.js"],"names":[],"mappings":"AAkCiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Ef"}
|