@nx/rspack 20.0.6 → 20.0.8
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/package.json +5 -5
- package/src/utils/generator-utils.js +20 -0
- package/src/utils/with-web.js +22 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rspack",
|
|
3
3
|
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
|
|
4
|
-
"version": "20.0.
|
|
4
|
+
"version": "20.0.8",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"generators": "./generators.json",
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nx/js": "20.0.
|
|
28
|
-
"@nx/devkit": "20.0.
|
|
29
|
-
"@nx/web": "20.0.
|
|
27
|
+
"@nx/js": "20.0.8",
|
|
28
|
+
"@nx/devkit": "20.0.8",
|
|
29
|
+
"@nx/web": "20.0.8",
|
|
30
30
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
31
31
|
"enquirer": "~2.3.6",
|
|
32
32
|
"express": "^4.19.2",
|
|
33
|
-
"http-proxy-middleware": "^3.0.
|
|
33
|
+
"http-proxy-middleware": "^3.0.3",
|
|
34
34
|
"less-loader": "11.1.0",
|
|
35
35
|
"license-webpack-plugin": "^4.0.2",
|
|
36
36
|
"sass-loader": "^12.2.0",
|
|
@@ -212,8 +212,28 @@ function createConfig(options, stylePreprocessorOptions) {
|
|
|
212
212
|
else if (options.framework === 'nest') {
|
|
213
213
|
return `
|
|
214
214
|
const { composePlugins, withNx } = require('@nx/rspack');
|
|
215
|
+
const rspack = require('@rspack/core');
|
|
215
216
|
|
|
216
217
|
module.exports = composePlugins(withNx(), (config) => {
|
|
218
|
+
config.optimization = {
|
|
219
|
+
minimizer: [
|
|
220
|
+
new rspack.SwcJsMinimizerRspackPlugin({
|
|
221
|
+
minimizerOptions: {
|
|
222
|
+
// We need to disable mangling and compression for class names and function names for Nest.js to work properly
|
|
223
|
+
// The execution context class returns a reference to the class/handler function, which is for example used for applying metadata using decorators
|
|
224
|
+
// https://docs.nestjs.com/fundamentals/execution-context#executioncontext-class
|
|
225
|
+
compress: {
|
|
226
|
+
keep_classnames: true,
|
|
227
|
+
keep_fnames: true,
|
|
228
|
+
},
|
|
229
|
+
mangle: {
|
|
230
|
+
keep_classnames: true,
|
|
231
|
+
keep_fnames: true,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
}),
|
|
235
|
+
],
|
|
236
|
+
};
|
|
217
237
|
return config;
|
|
218
238
|
});
|
|
219
239
|
`;
|
package/src/utils/with-web.js
CHANGED
|
@@ -96,11 +96,32 @@ function withWeb(opts = {}) {
|
|
|
96
96
|
template: options.indexHtml
|
|
97
97
|
? path.join(context.root, options.indexHtml)
|
|
98
98
|
: path.join(projectRoot, 'src/index.html'),
|
|
99
|
+
...(options.baseHref ? { base: { href: options.baseHref } } : {}),
|
|
99
100
|
}),
|
|
100
101
|
new core_1.rspack.EnvironmentPlugin({
|
|
101
|
-
NODE_ENV: 'development',
|
|
102
|
+
NODE_ENV: isProd ? 'production' : 'development',
|
|
102
103
|
}),
|
|
104
|
+
new core_1.rspack.DefinePlugin(getClientEnvironment(isProd ? 'production' : undefined).stringified),
|
|
103
105
|
],
|
|
104
106
|
};
|
|
105
107
|
};
|
|
106
108
|
}
|
|
109
|
+
function getClientEnvironment(mode) {
|
|
110
|
+
// Grab NODE_ENV and NX_PUBLIC_* environment variables and prepare them to be
|
|
111
|
+
// injected into the application via DefinePlugin in webpack configuration.
|
|
112
|
+
const nxPublicKeyRegex = /^NX_PUBLIC_/i;
|
|
113
|
+
const raw = Object.keys(process.env)
|
|
114
|
+
.filter((key) => nxPublicKeyRegex.test(key))
|
|
115
|
+
.reduce((env, key) => {
|
|
116
|
+
env[key] = process.env[key];
|
|
117
|
+
return env;
|
|
118
|
+
}, {});
|
|
119
|
+
// Stringify all values so we can feed into webpack DefinePlugin
|
|
120
|
+
const stringified = {
|
|
121
|
+
'process.env': Object.keys(raw).reduce((env, key) => {
|
|
122
|
+
env[key] = JSON.stringify(raw[key]);
|
|
123
|
+
return env;
|
|
124
|
+
}, {}),
|
|
125
|
+
};
|
|
126
|
+
return { stringified };
|
|
127
|
+
}
|