@workleap/webpack-configs 1.0.2 → 1.0.4
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/CHANGELOG.md +12 -0
- package/dist/build.d.ts +2 -2
- package/dist/build.js +3 -2
- package/dist/chunk-EF2WO5MC.js +17 -0
- package/dist/{chunk-SBBLJ5AL.js → chunk-IAMDZMFH.js} +20 -10
- package/dist/{chunk-IGATFK3O.js → chunk-NQR5SLK3.js} +17 -8
- package/dist/dev.d.ts +2 -2
- package/dist/dev.js +2 -2
- package/dist/index.js +3 -3
- package/dist/transformers/applyTransformers.d.ts +1 -0
- package/dist/transformers/applyTransformers.js +1 -1
- package/package.json +4 -3
- package/dist/chunk-URL2KA63.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @workleap/webpack-configs
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#127](https://github.com/gsoft-inc/wl-web-configs/pull/127) [`f440b12`](https://github.com/gsoft-inc/wl-web-configs/commit/f440b1251e2b3c1960dfc7f68bd090f573ec67d6) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Fix environment variables
|
|
8
|
+
|
|
9
|
+
## 1.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#123](https://github.com/gsoft-inc/wl-web-configs/pull/123) [`1c5458f`](https://github.com/gsoft-inc/wl-web-configs/commit/1c5458fba56494648b896e5263addaeb6380848e) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Updated web-configs
|
|
14
|
+
|
|
3
15
|
## 1.0.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/build.d.ts
CHANGED
|
@@ -15,11 +15,11 @@ interface DefineBuildConfigOptions {
|
|
|
15
15
|
cacheDirectory?: string;
|
|
16
16
|
moduleRules?: NonNullable<Configuration["module"]>["rules"];
|
|
17
17
|
plugins?: Configuration["plugins"];
|
|
18
|
-
htmlWebpackPlugin?:
|
|
18
|
+
htmlWebpackPlugin?: boolean | HtmlWebpackPlugin.Options;
|
|
19
19
|
miniCssExtractPluginOptions?: MiniCssExtractPluginOptions;
|
|
20
20
|
minify?: boolean;
|
|
21
21
|
cssModules?: boolean;
|
|
22
|
-
environmentVariables?: Record<string,
|
|
22
|
+
environmentVariables?: Record<string, unknown>;
|
|
23
23
|
transformers?: WebpackConfigTransformer[];
|
|
24
24
|
profile?: boolean;
|
|
25
25
|
}
|
package/dist/build.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-NQR5SLK3.js';
|
|
2
|
+
import './chunk-P2Z3EEVF.js';
|
|
3
|
+
import './chunk-EF2WO5MC.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/transformers/applyTransformers.ts
|
|
2
|
+
function applyTransformers(config, transformers, context) {
|
|
3
|
+
let count = 0;
|
|
4
|
+
const transformedConfig = transformers.reduce((acc, transformer) => {
|
|
5
|
+
transformer(acc, context);
|
|
6
|
+
count += 1;
|
|
7
|
+
return acc;
|
|
8
|
+
}, config);
|
|
9
|
+
if (context.profile) {
|
|
10
|
+
if (count > 0) {
|
|
11
|
+
console.log(`[webpack-configs] Applied ${count} configuration transformers.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return transformedConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { applyTransformers };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isObject } from './chunk-P2Z3EEVF.js';
|
|
2
|
-
import { applyTransformers } from './chunk-
|
|
2
|
+
import { applyTransformers } from './chunk-EF2WO5MC.js';
|
|
3
3
|
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
|
4
4
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
5
5
|
import { createRequire } from 'node:module';
|
|
@@ -53,7 +53,9 @@ function defineDevConfig(swcConfig, options = {}) {
|
|
|
53
53
|
htmlWebpackPlugin = defineDevHtmlWebpackPluginConfig(),
|
|
54
54
|
fastRefresh = true,
|
|
55
55
|
cssModules = false,
|
|
56
|
-
|
|
56
|
+
// Using an empty object literal as the default value to ensure
|
|
57
|
+
// "process.env" is always available.
|
|
58
|
+
environmentVariables = {},
|
|
57
59
|
transformers = [],
|
|
58
60
|
profile = false
|
|
59
61
|
} = options;
|
|
@@ -86,7 +88,7 @@ function defineDevConfig(swcConfig, options = {}) {
|
|
|
86
88
|
},
|
|
87
89
|
// Fixes caching for environmental variables using the DefinePlugin by forcing
|
|
88
90
|
// webpack caching to prioritize hashes over timestamps.
|
|
89
|
-
snapshot: {
|
|
91
|
+
snapshot: cache ? {
|
|
90
92
|
buildDependencies: {
|
|
91
93
|
hash: true,
|
|
92
94
|
timestamp: true
|
|
@@ -103,10 +105,12 @@ function defineDevConfig(swcConfig, options = {}) {
|
|
|
103
105
|
hash: true,
|
|
104
106
|
timestamp: true
|
|
105
107
|
}
|
|
106
|
-
},
|
|
108
|
+
} : void 0,
|
|
109
|
+
// See: https://webpack.js.org/guides/build-performance/#avoid-extra-optimization-steps
|
|
107
110
|
optimization: {
|
|
108
|
-
//
|
|
109
|
-
|
|
111
|
+
// Keep "runtimeChunk" to false, otherwise it breaks module federation
|
|
112
|
+
// (at least for the remote application).
|
|
113
|
+
runtimeChunk: false,
|
|
110
114
|
removeAvailableModules: false,
|
|
111
115
|
removeEmptyChunks: false,
|
|
112
116
|
splitChunks: false
|
|
@@ -167,17 +171,23 @@ function defineDevConfig(swcConfig, options = {}) {
|
|
|
167
171
|
}
|
|
168
172
|
},
|
|
169
173
|
plugins: [
|
|
170
|
-
htmlWebpackPlugin && new HtmlWebpackPlugin(htmlWebpackPlugin),
|
|
174
|
+
htmlWebpackPlugin && new HtmlWebpackPlugin(isObject(htmlWebpackPlugin) ? htmlWebpackPlugin : defineDevHtmlWebpackPluginConfig()),
|
|
175
|
+
// Stringify the environment variables because the plugin does a direct text replacement. Otherwise, "production" would become production
|
|
176
|
+
// after replacement and cause an undefined var error.
|
|
177
|
+
// For more information, view: https://webpack.js.org/plugins/define-plugin/.
|
|
171
178
|
new DefinePlugin({
|
|
172
|
-
|
|
173
|
-
|
|
179
|
+
"process.env": Object.keys(environmentVariables).reduce((acc, key) => {
|
|
180
|
+
acc[key] = JSON.stringify(environmentVariables[key]);
|
|
181
|
+
return acc;
|
|
182
|
+
}, {})
|
|
174
183
|
}),
|
|
175
184
|
fastRefresh && new ReactRefreshWebpackPlugin(isObject(fastRefresh) ? fastRefresh : defineFastRefreshPluginConfig()),
|
|
176
185
|
...plugins
|
|
177
186
|
].filter(Boolean)
|
|
178
187
|
};
|
|
179
188
|
const transformedConfig = applyTransformers(config, transformers, {
|
|
180
|
-
environment: "dev"
|
|
189
|
+
environment: "dev",
|
|
190
|
+
profile
|
|
181
191
|
});
|
|
182
192
|
return transformedConfig;
|
|
183
193
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObject } from './chunk-P2Z3EEVF.js';
|
|
2
|
+
import { applyTransformers } from './chunk-EF2WO5MC.js';
|
|
2
3
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
4
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
4
5
|
import { createRequire } from 'node:module';
|
|
@@ -43,7 +44,9 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
43
44
|
miniCssExtractPluginOptions = defineMiniCssExtractPluginConfig(),
|
|
44
45
|
minify = true,
|
|
45
46
|
cssModules = false,
|
|
46
|
-
|
|
47
|
+
// Using an empty object literal as the default value to ensure
|
|
48
|
+
// "process.env" is always available.
|
|
49
|
+
environmentVariables = {},
|
|
47
50
|
transformers = [],
|
|
48
51
|
profile = false
|
|
49
52
|
} = options;
|
|
@@ -67,7 +70,7 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
67
70
|
},
|
|
68
71
|
// Fixes caching for environmental variables using the DefinePlugin by forcing
|
|
69
72
|
// webpack caching to prioritize hashes over timestamps.
|
|
70
|
-
snapshot: {
|
|
73
|
+
snapshot: cache ? {
|
|
71
74
|
buildDependencies: {
|
|
72
75
|
hash: true,
|
|
73
76
|
timestamp: true
|
|
@@ -84,7 +87,7 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
84
87
|
hash: true,
|
|
85
88
|
timestamp: true
|
|
86
89
|
}
|
|
87
|
-
},
|
|
90
|
+
} : void 0,
|
|
88
91
|
optimization: minify ? {
|
|
89
92
|
minimize: true,
|
|
90
93
|
minimizer: [
|
|
@@ -153,17 +156,23 @@ function defineBuildConfig(swcConfig, options = {}) {
|
|
|
153
156
|
}
|
|
154
157
|
},
|
|
155
158
|
plugins: [
|
|
156
|
-
htmlWebpackPlugin && new HtmlWebpackPlugin(htmlWebpackPlugin),
|
|
159
|
+
htmlWebpackPlugin && new HtmlWebpackPlugin(isObject(htmlWebpackPlugin) ? htmlWebpackPlugin : defineBuildHtmlWebpackPluginConfig()),
|
|
157
160
|
new MiniCssExtractPlugin(miniCssExtractPluginOptions),
|
|
161
|
+
// Stringify the environment variables because the plugin does a direct text replacement. Otherwise, "production" would become production
|
|
162
|
+
// after replacement and cause an undefined var error because the production var doesn't exist.
|
|
163
|
+
// For more information, view: https://webpack.js.org/plugins/define-plugin.
|
|
158
164
|
new DefinePlugin({
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
"process.env": Object.keys(environmentVariables).reduce((acc, key) => {
|
|
166
|
+
acc[key] = JSON.stringify(environmentVariables[key]);
|
|
167
|
+
return acc;
|
|
168
|
+
}, {})
|
|
161
169
|
}),
|
|
162
170
|
...plugins
|
|
163
171
|
].filter(Boolean)
|
|
164
172
|
};
|
|
165
173
|
const transformedConfig = applyTransformers(config, transformers, {
|
|
166
|
-
environment: "build"
|
|
174
|
+
environment: "build",
|
|
175
|
+
profile
|
|
167
176
|
});
|
|
168
177
|
return transformedConfig;
|
|
169
178
|
}
|
package/dist/dev.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ interface DefineDevConfigOptions {
|
|
|
15
15
|
cacheDirectory?: string;
|
|
16
16
|
moduleRules?: NonNullable<Configuration["module"]>["rules"];
|
|
17
17
|
plugins?: Configuration["plugins"];
|
|
18
|
-
htmlWebpackPlugin?:
|
|
18
|
+
htmlWebpackPlugin?: boolean | HtmlWebpackPlugin.Options;
|
|
19
19
|
fastRefresh?: boolean | ReactRefreshPluginOptions;
|
|
20
20
|
cssModules?: boolean;
|
|
21
|
-
environmentVariables?: Record<string,
|
|
21
|
+
environmentVariables?: Record<string, unknown>;
|
|
22
22
|
transformers?: WebpackConfigTransformer[];
|
|
23
23
|
profile?: boolean;
|
|
24
24
|
}
|
package/dist/dev.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-
|
|
1
|
+
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-IAMDZMFH.js';
|
|
2
2
|
import './chunk-P2Z3EEVF.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-EF2WO5MC.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-
|
|
2
|
-
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-
|
|
1
|
+
export { defineBuildConfig, defineBuildHtmlWebpackPluginConfig, defineMiniCssExtractPluginConfig } from './chunk-NQR5SLK3.js';
|
|
2
|
+
export { defineDevConfig, defineDevHtmlWebpackPluginConfig, defineFastRefreshPluginConfig } from './chunk-IAMDZMFH.js';
|
|
3
3
|
import './chunk-P2Z3EEVF.js';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-EF2WO5MC.js';
|
|
5
5
|
export { addAfterModuleRule, addBeforeModuleRule, findModuleRule, findModuleRules, matchAssetModuleType, matchLoaderName, matchTest, removeModuleRules, replaceModuleRule } from './chunk-34O5ZLZ6.js';
|
|
6
6
|
export { addAfterPlugin, addBeforePlugin, findPlugin, matchConstructorName, removePlugin, replacePlugin } from './chunk-JPURRV2F.js';
|
|
@@ -2,6 +2,7 @@ import { Configuration } from 'webpack';
|
|
|
2
2
|
|
|
3
3
|
interface WebpackConfigTransformerContext {
|
|
4
4
|
environment: "dev" | "build";
|
|
5
|
+
profile: boolean;
|
|
5
6
|
}
|
|
6
7
|
type WebpackConfigTransformer = (config: Configuration, context: WebpackConfigTransformerContext) => Configuration;
|
|
7
8
|
declare function applyTransformers(config: Configuration, transformers: WebpackConfigTransformer[], context: WebpackConfigTransformerContext): Configuration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { applyTransformers } from '../chunk-
|
|
1
|
+
export { applyTransformers } from '../chunk-EF2WO5MC.js';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@workleap/webpack-configs",
|
|
3
3
|
"author": "Workleap",
|
|
4
4
|
"description": "Workleap recommended webpack config.",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.4",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"workleap",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@swc/helpers": "0.5.1",
|
|
57
57
|
"@swc/jest": "0.2.29",
|
|
58
58
|
"@types/jest": "29.5.4",
|
|
59
|
+
"@types/node": "20.5.7",
|
|
59
60
|
"browserslist": "4.21.10",
|
|
60
61
|
"jest": "29.6.4",
|
|
61
62
|
"postcss": "8.4.29",
|
|
@@ -67,8 +68,8 @@
|
|
|
67
68
|
"webpack-dev-server": "4.15.1",
|
|
68
69
|
"@workleap/eslint-plugin": "2.1.0",
|
|
69
70
|
"@workleap/swc-configs": "2.1.1",
|
|
70
|
-
"@workleap/
|
|
71
|
-
"@workleap/
|
|
71
|
+
"@workleap/typescript-configs": "3.0.2",
|
|
72
|
+
"@workleap/tsup-configs": "3.0.0"
|
|
72
73
|
},
|
|
73
74
|
"publishConfig": {
|
|
74
75
|
"access": "public",
|