@ohos-ports/nx-webpack 0.0.0-stage → 19.8.4-beta.1
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/LICENSE +22 -0
- package/README.md +67 -2
- package/app-plugin.d.ts +2 -0
- package/app-plugin.js +5 -0
- package/executors.json +19 -0
- package/generators.json +30 -0
- package/index.d.ts +25 -0
- package/index.js +32 -0
- package/migrations.json +64 -0
- package/package.json +83 -4
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/src/executors/dev-server/dev-server.impl.d.ts +7 -0
- package/src/executors/dev-server/dev-server.impl.js +89 -0
- package/src/executors/dev-server/lib/get-dev-server-config.d.ts +4 -0
- package/src/executors/dev-server/lib/get-dev-server-config.js +78 -0
- package/src/executors/dev-server/lib/serve-path.d.ts +3 -0
- package/src/executors/dev-server/lib/serve-path.js +44 -0
- package/src/executors/dev-server/schema.d.ts +17 -0
- package/src/executors/dev-server/schema.json +76 -0
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.d.ts +1 -0
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +38 -0
- package/src/executors/ssr-dev-server/schema.d.ts +11 -0
- package/src/executors/ssr-dev-server/schema.json +37 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.d.ts +8 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +37 -0
- package/src/executors/webpack/lib/normalize-options.d.ts +3 -0
- package/src/executors/webpack/lib/normalize-options.js +40 -0
- package/src/executors/webpack/lib/run-webpack.d.ts +3 -0
- package/src/executors/webpack/lib/run-webpack.js +35 -0
- package/src/executors/webpack/schema.d.ts +98 -0
- package/src/executors/webpack/schema.json +410 -0
- package/src/executors/webpack/webpack.impl.d.ts +13 -0
- package/src/executors/webpack/webpack.impl.js +123 -0
- package/src/generators/configuration/configuration.d.ts +5 -0
- package/src/generators/configuration/configuration.js +193 -0
- package/src/generators/configuration/schema.d.ts +14 -0
- package/src/generators/configuration/schema.json +77 -0
- package/src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.d.ts +7 -0
- package/src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.js +92 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.d.ts +6 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.js +105 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/normalize-path-options.d.ts +2 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/normalize-path-options.js +74 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/utils.d.ts +1 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/utils.js +13 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/validate-project.d.ts +9 -0
- package/src/generators/convert-config-to-webpack-plugin/lib/validate-project.js +43 -0
- package/src/generators/convert-config-to-webpack-plugin/schema.json +19 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +12 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.js +114 -0
- package/src/generators/convert-to-inferred/schema.json +19 -0
- package/src/generators/convert-to-inferred/utils/ast.d.ts +3 -0
- package/src/generators/convert-to-inferred/utils/ast.js +39 -0
- package/src/generators/convert-to-inferred/utils/build-post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +218 -0
- package/src/generators/convert-to-inferred/utils/index.d.ts +3 -0
- package/src/generators/convert-to-inferred/utils/index.js +6 -0
- package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +249 -0
- package/src/generators/convert-to-inferred/utils/types.d.ts +11 -0
- package/src/generators/convert-to-inferred/utils/types.js +2 -0
- package/src/generators/init/init.d.ts +5 -0
- package/src/generators/init/init.js +58 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +33 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-17-2-1/webpack-config-setup.d.ts +2 -0
- package/src/migrations/update-17-2-1/webpack-config-setup.js +31 -0
- package/src/migrations/update-19-6-3/proxy-config.d.ts +2 -0
- package/src/migrations/update-19-6-3/proxy-config.js +57 -0
- package/src/plugins/generate-package-json-plugin.d.ts +15 -0
- package/src/plugins/generate-package-json-plugin.js +45 -0
- package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +8 -0
- package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +50 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +5 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +328 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +5 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-web-config.js +365 -0
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +53 -0
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +81 -0
- package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts +1 -0
- package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.js +34 -0
- package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +3 -0
- package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.js +41 -0
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +4 -0
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +171 -0
- package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +73 -0
- package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +118 -0
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.d.ts +236 -0
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.js +2 -0
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.d.ts +17 -0
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.js +48 -0
- package/src/plugins/plugin.d.ts +13 -0
- package/src/plugins/plugin.js +197 -0
- package/src/plugins/stats-json-plugin.d.ts +4 -0
- package/src/plugins/stats-json-plugin.js +13 -0
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.d.ts +31 -0
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +70 -0
- package/src/plugins/webpack-nx-build-coordination-plugin.d.ts +11 -0
- package/src/plugins/webpack-nx-build-coordination-plugin.js +94 -0
- package/src/plugins/write-index-html-plugin.d.ts +22 -0
- package/src/plugins/write-index-html-plugin.js +249 -0
- package/src/utils/config.d.ts +22 -0
- package/src/utils/config.js +67 -0
- package/src/utils/create-copy-plugin.d.ts +3 -0
- package/src/utils/create-copy-plugin.js +25 -0
- package/src/utils/e2e-web-server-info-utils.d.ts +2 -0
- package/src/utils/e2e-web-server-info-utils.js +25 -0
- package/src/utils/ensure-dependencies.d.ts +6 -0
- package/src/utils/ensure-dependencies.js +26 -0
- package/src/utils/fs.d.ts +6 -0
- package/src/utils/fs.js +57 -0
- package/src/utils/get-client-environment.d.ts +5 -0
- package/src/utils/get-client-environment.js +28 -0
- package/src/utils/get-css-module-local-ident.d.ts +1 -0
- package/src/utils/get-css-module-local-ident.js +17 -0
- package/src/utils/has-plugin.d.ts +2 -0
- package/src/utils/has-plugin.js +10 -0
- package/src/utils/hash-format.d.ts +7 -0
- package/src/utils/hash-format.js +22 -0
- package/src/utils/models.d.ts +23 -0
- package/src/utils/models.js +2 -0
- package/src/utils/module-federation/dependencies.d.ts +6 -0
- package/src/utils/module-federation/dependencies.js +56 -0
- package/src/utils/module-federation/get-remotes-for-host.d.ts +16 -0
- package/src/utils/module-federation/get-remotes-for-host.js +97 -0
- package/src/utils/module-federation/index.d.ts +6 -0
- package/src/utils/module-federation/index.js +9 -0
- package/src/utils/module-federation/models/index.d.ts +47 -0
- package/src/utils/module-federation/models/index.js +2 -0
- package/src/utils/module-federation/package-json.d.ts +8 -0
- package/src/utils/module-federation/package-json.js +12 -0
- package/src/utils/module-federation/parse-static-remotes-config.d.ts +13 -0
- package/src/utils/module-federation/parse-static-remotes-config.js +34 -0
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.d.ts +3 -0
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +54 -0
- package/src/utils/module-federation/public-api.d.ts +6 -0
- package/src/utils/module-federation/public-api.js +16 -0
- package/src/utils/module-federation/remotes.d.ts +19 -0
- package/src/utils/module-federation/remotes.js +79 -0
- package/src/utils/module-federation/secondary-entry-points.d.ts +12 -0
- package/src/utils/module-federation/secondary-entry-points.js +125 -0
- package/src/utils/module-federation/share.d.ts +48 -0
- package/src/utils/module-federation/share.js +240 -0
- package/src/utils/module-federation/start-remote-proxies.d.ts +5 -0
- package/src/utils/module-federation/start-remote-proxies.js +38 -0
- package/src/utils/module-federation/start-ssr-remote-proxies.d.ts +5 -0
- package/src/utils/module-federation/start-ssr-remote-proxies.js +52 -0
- package/src/utils/module-federation/typescript.d.ts +4 -0
- package/src/utils/module-federation/typescript.js +53 -0
- package/src/utils/run-webpack.d.ts +5 -0
- package/src/utils/run-webpack.js +30 -0
- package/src/utils/versions.d.ts +7 -0
- package/src/utils/versions.js +11 -0
- package/src/utils/web-babel-loader.d.ts +0 -0
- package/src/utils/web-babel-loader.js +17 -0
- package/src/utils/webpack/deprecated-stylus-loader.d.ts +1 -0
- package/src/utils/webpack/deprecated-stylus-loader.js +11 -0
- package/src/utils/webpack/interpolate-env-variables-to-index.d.ts +1 -0
- package/src/utils/webpack/interpolate-env-variables-to-index.js +29 -0
- package/src/utils/webpack/normalize-entry.d.ts +2 -0
- package/src/utils/webpack/normalize-entry.js +27 -0
- package/src/utils/webpack/package-chunk-sort.d.ts +5 -0
- package/src/utils/webpack/package-chunk-sort.js +30 -0
- package/src/utils/webpack/plugins/postcss-cli-resources.d.ts +14 -0
- package/src/utils/webpack/plugins/postcss-cli-resources.js +164 -0
- package/src/utils/webpack/plugins/scripts-webpack-plugin.d.ts +17 -0
- package/src/utils/webpack/plugins/scripts-webpack-plugin.js +119 -0
- package/src/utils/webpack/read-webpack-options.d.ts +10 -0
- package/src/utils/webpack/read-webpack-options.js +40 -0
- package/src/utils/webpack/resolve-user-defined-webpack-config.d.ts +3 -0
- package/src/utils/webpack/resolve-user-defined-webpack-config.js +37 -0
- package/src/utils/with-nx.d.ts +8 -0
- package/src/utils/with-nx.js +33 -0
- package/src/utils/with-web.d.ts +22 -0
- package/src/utils/with-web.js +25 -0
- package/tsconfig-paths-plugin.d.ts +1 -0
- package/tsconfig-paths-plugin.js +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2024 Narwhal Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<div style="text-align: center;">
|
|
9
|
+
|
|
10
|
+
[](https://circleci.com/gh/nrwl/nx)
|
|
11
|
+
[]()
|
|
12
|
+
[](https://www.npmjs.com/@nx/workspace)
|
|
13
|
+
[]()
|
|
14
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
15
|
+
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
16
|
+
[](https://go.nx.dev/community)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<hr>
|
|
22
|
+
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
24
|
+
|
|
25
|
+
Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
|
|
26
|
+
|
|
27
|
+
This package is a [Webpack plugin for Nx](https://nx.dev/nx-api/webpack).
|
|
28
|
+
|
|
29
|
+
## Getting Started
|
|
30
|
+
|
|
31
|
+
### Creating an Nx Workspace
|
|
32
|
+
|
|
33
|
+
**Using `npx`**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx create-nx-workspace
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Using `npm init`**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm init nx-workspace
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Using `yarn create`**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
yarn create nx-workspace
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Adding Nx to an Existing Repository
|
|
52
|
+
|
|
53
|
+
Run:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx nx@latest init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Documentation & Resources
|
|
60
|
+
|
|
61
|
+
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
|
|
62
|
+
- [Intro to Nx](https://nx.dev/getting-started/intro)
|
|
63
|
+
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
|
|
64
|
+
- [Blog Posts About Nx](https://nx.dev/blog)
|
|
65
|
+
|
|
66
|
+
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
67
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
2
68
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/app-plugin.d.ts
ADDED
package/app-plugin.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxAppWebpackPlugin = void 0;
|
|
4
|
+
var nx_app_webpack_plugin_1 = require("./src/plugins/nx-webpack-plugin/nx-app-webpack-plugin");
|
|
5
|
+
Object.defineProperty(exports, "NxAppWebpackPlugin", { enumerable: true, get: function () { return nx_app_webpack_plugin_1.NxAppWebpackPlugin; } });
|
package/executors.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executors": {
|
|
3
|
+
"webpack": {
|
|
4
|
+
"implementation": "./src/executors/webpack/webpack.impl",
|
|
5
|
+
"schema": "./src/executors/webpack/schema.json",
|
|
6
|
+
"description": "Run webpack build."
|
|
7
|
+
},
|
|
8
|
+
"dev-server": {
|
|
9
|
+
"implementation": "./src/executors/dev-server/dev-server.impl",
|
|
10
|
+
"schema": "./src/executors/dev-server/schema.json",
|
|
11
|
+
"description": "Serve a web application."
|
|
12
|
+
},
|
|
13
|
+
"ssr-dev-server": {
|
|
14
|
+
"implementation": "./src/executors/ssr-dev-server/ssr-dev-server.impl",
|
|
15
|
+
"schema": "./src/executors/ssr-dev-server/schema.json",
|
|
16
|
+
"description": "Serve a SSR application."
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/generators.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Nx Webpack",
|
|
3
|
+
"version": "0.1",
|
|
4
|
+
"generators": {
|
|
5
|
+
"init": {
|
|
6
|
+
"factory": "./src/generators/init/init#webpackInitGeneratorInternal",
|
|
7
|
+
"schema": "./src/generators/init/schema.json",
|
|
8
|
+
"description": "Initialize the `@nx/webpack` plugin.",
|
|
9
|
+
"aliases": ["ng-add"],
|
|
10
|
+
"hidden": true
|
|
11
|
+
},
|
|
12
|
+
"configuration": {
|
|
13
|
+
"aliases": ["webpack-project"],
|
|
14
|
+
"factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
|
|
15
|
+
"schema": "./src/generators/configuration/schema.json",
|
|
16
|
+
"description": "Add webpack configuration to a project.",
|
|
17
|
+
"hidden": true
|
|
18
|
+
},
|
|
19
|
+
"convert-config-to-webpack-plugin": {
|
|
20
|
+
"factory": "./src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin",
|
|
21
|
+
"schema": "./src/generators/convert-config-to-webpack-plugin/schema.json",
|
|
22
|
+
"description": "Convert the project to use the `NxAppWebpackPlugin` and `NxReactWebpackPlugin`."
|
|
23
|
+
},
|
|
24
|
+
"convert-to-inferred": {
|
|
25
|
+
"factory": "./src/generators/convert-to-inferred/convert-to-inferred#convertToInferred",
|
|
26
|
+
"schema": "./src/generators/convert-to-inferred/schema.json",
|
|
27
|
+
"description": "Convert existing Webpack project(s) using `@nx/webpack:wepack` executor to use `@nx/webpack/plugin`."
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { configurationGenerator } from './src/generators/configuration/configuration';
|
|
2
|
+
import { NxAppWebpackPlugin } from './src/plugins/nx-webpack-plugin/nx-app-webpack-plugin';
|
|
3
|
+
import { NxTsconfigPathsWebpackPlugin as _NxTsconfigPathsWebpackPlugin } from './src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin';
|
|
4
|
+
import { convertConfigToWebpackPluginGenerator } from './src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin';
|
|
5
|
+
import { useLegacyNxPlugin } from './src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin';
|
|
6
|
+
export { configurationGenerator, convertConfigToWebpackPluginGenerator, useLegacyNxPlugin, };
|
|
7
|
+
/** @deprecated Use `configurationGenerator` instead. */
|
|
8
|
+
export declare const webpackProjectGenerator: typeof configurationGenerator;
|
|
9
|
+
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
|
|
10
|
+
export declare const NxWebpackPlugin: typeof NxAppWebpackPlugin;
|
|
11
|
+
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
12
|
+
export declare const NxTsconfigPathsWebpackPlugin: typeof _NxTsconfigPathsWebpackPlugin;
|
|
13
|
+
export * from './src/utils/create-copy-plugin';
|
|
14
|
+
export * from './src/utils/config';
|
|
15
|
+
export { webpackInitGenerator } from './src/generators/init/init';
|
|
16
|
+
export type { WebDevServerOptions } from './src/executors/dev-server/schema';
|
|
17
|
+
export * from './src/executors/dev-server/dev-server.impl';
|
|
18
|
+
export * from './src/executors/webpack/lib/normalize-options';
|
|
19
|
+
export type { WebpackExecutorOptions, NormalizedWebpackExecutorOptions, AssetGlobPattern, FileReplacement, } from './src/executors/webpack/schema';
|
|
20
|
+
export * from './src/executors/webpack/webpack.impl';
|
|
21
|
+
export * from './src/utils/get-css-module-local-ident';
|
|
22
|
+
export * from './src/utils/with-nx';
|
|
23
|
+
export * from './src/utils/with-web';
|
|
24
|
+
export * from './src/utils/module-federation/public-api';
|
|
25
|
+
export * from './src/utils/e2e-web-server-info-utils';
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webpackInitGenerator = exports.NxTsconfigPathsWebpackPlugin = exports.NxWebpackPlugin = exports.webpackProjectGenerator = exports.useLegacyNxPlugin = exports.convertConfigToWebpackPluginGenerator = exports.configurationGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const configuration_1 = require("./src/generators/configuration/configuration");
|
|
6
|
+
Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
|
|
7
|
+
const nx_app_webpack_plugin_1 = require("./src/plugins/nx-webpack-plugin/nx-app-webpack-plugin");
|
|
8
|
+
const nx_tsconfig_paths_webpack_plugin_1 = require("./src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin");
|
|
9
|
+
const convert_config_to_webpack_plugin_1 = require("./src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin");
|
|
10
|
+
Object.defineProperty(exports, "convertConfigToWebpackPluginGenerator", { enumerable: true, get: function () { return convert_config_to_webpack_plugin_1.convertConfigToWebpackPluginGenerator; } });
|
|
11
|
+
const use_legacy_nx_plugin_1 = require("./src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin");
|
|
12
|
+
Object.defineProperty(exports, "useLegacyNxPlugin", { enumerable: true, get: function () { return use_legacy_nx_plugin_1.useLegacyNxPlugin; } });
|
|
13
|
+
// Exported for backwards compatibility in case a plugin is using the old name.
|
|
14
|
+
/** @deprecated Use `configurationGenerator` instead. */
|
|
15
|
+
exports.webpackProjectGenerator = configuration_1.configurationGenerator;
|
|
16
|
+
// TODO(v20): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
|
|
17
|
+
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
|
|
18
|
+
exports.NxWebpackPlugin = nx_app_webpack_plugin_1.NxAppWebpackPlugin;
|
|
19
|
+
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
20
|
+
exports.NxTsconfigPathsWebpackPlugin = nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin;
|
|
21
|
+
tslib_1.__exportStar(require("./src/utils/create-copy-plugin"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./src/utils/config"), exports);
|
|
23
|
+
var init_1 = require("./src/generators/init/init");
|
|
24
|
+
Object.defineProperty(exports, "webpackInitGenerator", { enumerable: true, get: function () { return init_1.webpackInitGenerator; } });
|
|
25
|
+
tslib_1.__exportStar(require("./src/executors/dev-server/dev-server.impl"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./src/executors/webpack/lib/normalize-options"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./src/executors/webpack/webpack.impl"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./src/utils/get-css-module-local-ident"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./src/utils/with-nx"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./src/utils/with-web"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./src/utils/module-federation/public-api"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./src/utils/e2e-web-server-info-utils"), exports);
|
package/migrations.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"update-16-0-0-add-nx-packages": {
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"version": "16.0.0-beta.1",
|
|
6
|
+
"description": "Replace @nrwl/webpack with @nx/webpack",
|
|
7
|
+
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
+
},
|
|
9
|
+
"update-17-2-1-webpack-config-setup": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "17.2.1-beta.0",
|
|
12
|
+
"description": "Add webpack.config.js file when webpackConfig is not defined",
|
|
13
|
+
"implementation": "./src/migrations/update-17-2-1/webpack-config-setup"
|
|
14
|
+
},
|
|
15
|
+
"update-19-6-3-proxy-config": {
|
|
16
|
+
"cli": "nx",
|
|
17
|
+
"version": "19.6.3-beta.0",
|
|
18
|
+
"description": "Migrate proxy config files to match new format from webpack-dev-server v5.",
|
|
19
|
+
"implementation": "./src/migrations/update-19-6-3/proxy-config"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"packageJsonUpdates": {
|
|
23
|
+
"16.3.0": {
|
|
24
|
+
"version": "16.3.0-beta.8",
|
|
25
|
+
"packages": {
|
|
26
|
+
"@svgr/webpack": {
|
|
27
|
+
"version": "^8.0.1",
|
|
28
|
+
"alwaysAddToPackageJson": false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"16.4.1": {
|
|
33
|
+
"version": "16.4.1-beta.0",
|
|
34
|
+
"packages": {
|
|
35
|
+
"webpack": {
|
|
36
|
+
"version": "^5.80.0",
|
|
37
|
+
"alwaysAddToPackageJson": false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"19.6.0": {
|
|
42
|
+
"version": "19.6.0-beta.1",
|
|
43
|
+
"packages": {
|
|
44
|
+
"webpack-dev-server": {
|
|
45
|
+
"version": "^5.0.4",
|
|
46
|
+
"alwaysAddToPackageJson": false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"19.7.0": {
|
|
51
|
+
"version": "19.7.0-beta.4",
|
|
52
|
+
"packages": {
|
|
53
|
+
"@module-federation/enhanced": {
|
|
54
|
+
"version": "~0.6.0",
|
|
55
|
+
"alwaysAddToPackageJson": false
|
|
56
|
+
},
|
|
57
|
+
"@module-federation/sdk": {
|
|
58
|
+
"version": "~0.6.0",
|
|
59
|
+
"alwaysAddToPackageJson": false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/nx-webpack",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "19.8.4-beta.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
9
|
+
"directory": "ports/nx-webpack/19.8.4"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Monorepo",
|
|
13
|
+
"Webpack",
|
|
14
|
+
"Web",
|
|
15
|
+
"CLI",
|
|
16
|
+
"Front-end"
|
|
17
|
+
],
|
|
18
|
+
"main": "./index",
|
|
19
|
+
"typings": "./index.d.ts",
|
|
20
|
+
"author": "Victor Savkin",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/ohos-ports/ohos-ports/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://nx.dev",
|
|
26
|
+
"generators": "./generators.json",
|
|
27
|
+
"executors": "./executors.json",
|
|
28
|
+
"ng-update": {
|
|
29
|
+
"requirements": {},
|
|
30
|
+
"migrations": "./migrations.json"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@babel/core": "^7.23.2",
|
|
34
|
+
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
|
+
"@module-federation/sdk": "^0.6.0",
|
|
36
|
+
"@module-federation/enhanced": "^0.6.0",
|
|
37
|
+
"ajv": "^8.12.0",
|
|
38
|
+
"autoprefixer": "^10.4.9",
|
|
39
|
+
"babel-loader": "^9.1.2",
|
|
40
|
+
"browserslist": "^4.21.4",
|
|
41
|
+
"chalk": "^4.1.0",
|
|
42
|
+
"copy-webpack-plugin": "^10.2.4",
|
|
43
|
+
"css-loader": "^6.4.0",
|
|
44
|
+
"css-minimizer-webpack-plugin": "^5.0.0",
|
|
45
|
+
"express": "^4.19.2",
|
|
46
|
+
"fork-ts-checker-webpack-plugin": "7.2.13",
|
|
47
|
+
"http-proxy-middleware": "^3.0.0",
|
|
48
|
+
"less": "4.1.3",
|
|
49
|
+
"less-loader": "11.1.0",
|
|
50
|
+
"license-webpack-plugin": "^4.0.2",
|
|
51
|
+
"loader-utils": "^2.0.3",
|
|
52
|
+
"mini-css-extract-plugin": "~2.4.7",
|
|
53
|
+
"parse5": "4.0.0",
|
|
54
|
+
"postcss": "^8.4.38",
|
|
55
|
+
"postcss-import": "~14.1.0",
|
|
56
|
+
"postcss-loader": "^6.1.1",
|
|
57
|
+
"rxjs": "^7.8.0",
|
|
58
|
+
"sass": "^1.42.1",
|
|
59
|
+
"sass-loader": "^12.2.0",
|
|
60
|
+
"source-map-loader": "^5.0.0",
|
|
61
|
+
"style-loader": "^3.3.0",
|
|
62
|
+
"stylus": "^0.59.0",
|
|
63
|
+
"stylus-loader": "^7.1.0",
|
|
64
|
+
"terser-webpack-plugin": "^5.3.3",
|
|
65
|
+
"ts-loader": "^9.3.1",
|
|
66
|
+
"tsconfig-paths-webpack-plugin": "4.0.0",
|
|
67
|
+
"tslib": "^2.3.0",
|
|
68
|
+
"webpack": "^5.80.0",
|
|
69
|
+
"webpack-dev-server": "^5.0.4",
|
|
70
|
+
"webpack-node-externals": "^3.0.0",
|
|
71
|
+
"webpack-subresource-integrity": "^5.1.0",
|
|
72
|
+
"@nx/devkit": "npm:@ohos-ports/nx-devkit@^19.8.4-beta.3",
|
|
73
|
+
"@nx/js": "npm:@ohos-ports/nx-js@^19.8.4-beta.3",
|
|
74
|
+
"@nrwl/webpack": "npm:@ohos-ports/nrwl-webpack@^19.8.4-beta.2",
|
|
75
|
+
"nx": "npm:@ohos-ports/nx@^19.8.4-beta.2"
|
|
76
|
+
},
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"access": "public"
|
|
79
|
+
},
|
|
80
|
+
"type": "commonjs",
|
|
81
|
+
"types": "./index.d.ts",
|
|
82
|
+
"optionalDependencies": {
|
|
83
|
+
"nx": "npm:@ohos-ports/nx@^19.8.4-beta.2"
|
|
84
|
+
}
|
|
85
|
+
}
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createNodes, createNodesV2, type WebpackPluginOptions, } from './src/plugins/plugin';
|
package/plugin.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodesV2 = exports.createNodes = void 0;
|
|
4
|
+
var plugin_1 = require("./src/plugins/plugin");
|
|
5
|
+
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
6
|
+
Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { WebDevServerOptions } from './schema';
|
|
3
|
+
export declare function devServerExecutor(serveOptions: WebDevServerOptions, context: ExecutorContext): AsyncGenerator<{
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
success: boolean;
|
|
6
|
+
}, any, undefined>;
|
|
7
|
+
export default devServerExecutor;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.devServerExecutor = devServerExecutor;
|
|
4
|
+
const webpack = require("webpack");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
7
|
+
const operators_1 = require("rxjs/operators");
|
|
8
|
+
const WebpackDevServer = require("webpack-dev-server");
|
|
9
|
+
const get_dev_server_config_1 = require("./lib/get-dev-server-config");
|
|
10
|
+
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
11
|
+
const run_webpack_1 = require("../../utils/run-webpack");
|
|
12
|
+
const resolve_user_defined_webpack_config_1 = require("../../utils/webpack/resolve-user-defined-webpack-config");
|
|
13
|
+
const normalize_options_1 = require("../webpack/lib/normalize-options");
|
|
14
|
+
const config_1 = require("../../utils/config");
|
|
15
|
+
const js_1 = require("@nx/js");
|
|
16
|
+
async function* devServerExecutor(serveOptions, context) {
|
|
17
|
+
// Default to dev mode so builds are faster and HMR mode works better.
|
|
18
|
+
process.env.NODE_ENV ??= 'development';
|
|
19
|
+
const { root: projectRoot, sourceRoot } = context.projectsConfigurations.projects[context.projectName];
|
|
20
|
+
const buildOptions = (0, normalize_options_1.normalizeOptions)(getBuildOptions(serveOptions, context), context.root, projectRoot, sourceRoot);
|
|
21
|
+
process.env.NX_BUILD_LIBS_FROM_SOURCE = `${buildOptions.buildLibsFromSource}`;
|
|
22
|
+
process.env.NX_BUILD_TARGET = serveOptions.buildTarget;
|
|
23
|
+
// TODO(jack): Figure out a way to port this into NxWebpackPlugin
|
|
24
|
+
if (!buildOptions.buildLibsFromSource) {
|
|
25
|
+
if (!buildOptions.tsConfig) {
|
|
26
|
+
throw new Error(`Cannot find "tsConfig" to remap paths for. Set this option in project.json.`);
|
|
27
|
+
}
|
|
28
|
+
const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, 'build', // should be generalized
|
|
29
|
+
context.configurationName);
|
|
30
|
+
buildOptions.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(buildOptions.tsConfig, context.root, target.data.root, dependencies);
|
|
31
|
+
process.env.NX_TSCONFIG_PATH = buildOptions.tsConfig;
|
|
32
|
+
}
|
|
33
|
+
let config;
|
|
34
|
+
const devServer = (0, get_dev_server_config_1.getDevServerOptions)(context.root, serveOptions, buildOptions);
|
|
35
|
+
if (buildOptions.webpackConfig) {
|
|
36
|
+
let userDefinedWebpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)(buildOptions.webpackConfig, (0, js_1.getRootTsConfigPath)());
|
|
37
|
+
if (typeof userDefinedWebpackConfig.then === 'function') {
|
|
38
|
+
userDefinedWebpackConfig = await userDefinedWebpackConfig;
|
|
39
|
+
}
|
|
40
|
+
// Only add the dev server option if user is composable plugin.
|
|
41
|
+
// Otherwise, user should define `devServer` option directly in their webpack config.
|
|
42
|
+
if (typeof userDefinedWebpackConfig === 'function' &&
|
|
43
|
+
((0, config_1.isNxWebpackComposablePlugin)(userDefinedWebpackConfig) ||
|
|
44
|
+
!buildOptions.standardWebpackConfigFunction)) {
|
|
45
|
+
config = await userDefinedWebpackConfig({ devServer }, {
|
|
46
|
+
options: buildOptions,
|
|
47
|
+
context,
|
|
48
|
+
configuration: serveOptions.buildTarget.split(':')[2],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else if (userDefinedWebpackConfig) {
|
|
52
|
+
// New behavior, we want the webpack config to export object
|
|
53
|
+
// If the config is a function, we assume it's a standard webpack config function and it's async
|
|
54
|
+
if (typeof userDefinedWebpackConfig === 'function') {
|
|
55
|
+
config = await userDefinedWebpackConfig(process.env.NODE_ENV, {});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
config = userDefinedWebpackConfig;
|
|
59
|
+
}
|
|
60
|
+
config.devServer ??= devServer;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return yield* (0, rxjs_for_await_1.eachValueFrom)((0, run_webpack_1.runWebpackDevServer)(config, webpack, WebpackDevServer).pipe((0, operators_1.tap)(({ stats }) => {
|
|
64
|
+
console.info(stats.toString(config.stats));
|
|
65
|
+
}), (0, operators_1.map)(({ baseUrl, stats }) => {
|
|
66
|
+
return {
|
|
67
|
+
baseUrl,
|
|
68
|
+
success: !stats.hasErrors(),
|
|
69
|
+
};
|
|
70
|
+
})));
|
|
71
|
+
}
|
|
72
|
+
function getBuildOptions(options, context) {
|
|
73
|
+
const target = (0, devkit_1.parseTargetString)(options.buildTarget, context);
|
|
74
|
+
const overrides = {
|
|
75
|
+
watch: false,
|
|
76
|
+
};
|
|
77
|
+
if (options.memoryLimit) {
|
|
78
|
+
overrides.memoryLimit = options.memoryLimit;
|
|
79
|
+
}
|
|
80
|
+
if (options.baseHref) {
|
|
81
|
+
overrides.baseHref = options.baseHref;
|
|
82
|
+
}
|
|
83
|
+
const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
|
|
84
|
+
return {
|
|
85
|
+
...buildOptions,
|
|
86
|
+
...overrides,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
exports.default = devServerExecutor;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
2
|
+
import { WebDevServerOptions } from '../schema';
|
|
3
|
+
import { NormalizedWebpackExecutorOptions } from '../../webpack/schema';
|
|
4
|
+
export declare function getDevServerOptions(root: string, serveOptions: WebDevServerOptions, buildOptions: NormalizedWebpackExecutorOptions): WebpackDevServerConfiguration;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDevServerOptions = getDevServerOptions;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const serve_path_1 = require("./serve-path");
|
|
8
|
+
function getDevServerOptions(root, serveOptions, buildOptions) {
|
|
9
|
+
const servePath = (0, serve_path_1.buildServePath)(buildOptions);
|
|
10
|
+
let scriptsOptimization;
|
|
11
|
+
let stylesOptimization;
|
|
12
|
+
if (typeof buildOptions.optimization === 'boolean') {
|
|
13
|
+
scriptsOptimization = stylesOptimization = buildOptions.optimization;
|
|
14
|
+
}
|
|
15
|
+
else if (buildOptions.optimization) {
|
|
16
|
+
scriptsOptimization = buildOptions.optimization.scripts;
|
|
17
|
+
stylesOptimization = buildOptions.optimization.styles;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
scriptsOptimization = stylesOptimization = false;
|
|
21
|
+
}
|
|
22
|
+
const config = {
|
|
23
|
+
host: serveOptions.host,
|
|
24
|
+
port: serveOptions.port,
|
|
25
|
+
headers: { 'Access-Control-Allow-Origin': '*' },
|
|
26
|
+
historyApiFallback: {
|
|
27
|
+
index: buildOptions.index &&
|
|
28
|
+
`${servePath}${path.basename(buildOptions.index)}`,
|
|
29
|
+
disableDotRule: true,
|
|
30
|
+
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
|
|
31
|
+
},
|
|
32
|
+
onListening(server) {
|
|
33
|
+
const isHttps = server.options.https || server.options.server?.type === 'https';
|
|
34
|
+
devkit_1.logger.info(`NX Web Development Server is listening at ${isHttps ? 'https' : 'http'}://${server.options.host}:${server.options.port}${(0, serve_path_1.buildServePath)(buildOptions)}`);
|
|
35
|
+
},
|
|
36
|
+
open: serveOptions.open,
|
|
37
|
+
static: false,
|
|
38
|
+
compress: scriptsOptimization || stylesOptimization,
|
|
39
|
+
devMiddleware: {
|
|
40
|
+
publicPath: servePath,
|
|
41
|
+
stats: false,
|
|
42
|
+
},
|
|
43
|
+
client: {
|
|
44
|
+
webSocketURL: serveOptions.publicHost,
|
|
45
|
+
overlay: {
|
|
46
|
+
errors: !(scriptsOptimization || stylesOptimization),
|
|
47
|
+
warnings: false,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
liveReload: serveOptions.hmr ? false : serveOptions.liveReload, // disable liveReload if hmr is enabled
|
|
51
|
+
hot: serveOptions.hmr,
|
|
52
|
+
};
|
|
53
|
+
if (serveOptions.ssl) {
|
|
54
|
+
config.server = {
|
|
55
|
+
type: 'https',
|
|
56
|
+
};
|
|
57
|
+
if (serveOptions.sslKey && serveOptions.sslCert) {
|
|
58
|
+
config.server.options = getSslConfig(root, serveOptions);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (serveOptions.proxyConfig) {
|
|
62
|
+
config.proxy = getProxyConfig(root, serveOptions);
|
|
63
|
+
}
|
|
64
|
+
if (serveOptions.allowedHosts) {
|
|
65
|
+
config.allowedHosts = serveOptions.allowedHosts.split(',');
|
|
66
|
+
}
|
|
67
|
+
return config;
|
|
68
|
+
}
|
|
69
|
+
function getSslConfig(root, options) {
|
|
70
|
+
return {
|
|
71
|
+
key: (0, fs_1.readFileSync)(path.resolve(root, options.sslKey), 'utf-8'),
|
|
72
|
+
cert: (0, fs_1.readFileSync)(path.resolve(root, options.sslCert), 'utf-8'),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function getProxyConfig(root, options) {
|
|
76
|
+
const proxyPath = path.resolve(root, options.proxyConfig);
|
|
77
|
+
return require(proxyPath);
|
|
78
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { NormalizedWebpackExecutorOptions } from '../../webpack/schema';
|
|
2
|
+
export declare function buildServePath(browserOptions: NormalizedWebpackExecutorOptions): string;
|
|
3
|
+
export declare function _findDefaultServePath(baseHref?: string, deployUrl?: string): string | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildServePath = buildServePath;
|
|
4
|
+
exports._findDefaultServePath = _findDefaultServePath;
|
|
5
|
+
function buildServePath(browserOptions) {
|
|
6
|
+
let servePath = _findDefaultServePath(browserOptions.baseHref, browserOptions.deployUrl) ||
|
|
7
|
+
'/';
|
|
8
|
+
if (servePath.endsWith('/')) {
|
|
9
|
+
servePath = servePath.slice(0, -1);
|
|
10
|
+
}
|
|
11
|
+
if (!servePath.startsWith('/')) {
|
|
12
|
+
servePath = `/${servePath}`;
|
|
13
|
+
}
|
|
14
|
+
return servePath;
|
|
15
|
+
}
|
|
16
|
+
function _findDefaultServePath(baseHref, deployUrl) {
|
|
17
|
+
if (!baseHref && !deployUrl) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
if (/^(\w+:)?\/\//.test(baseHref || '') ||
|
|
21
|
+
/^(\w+:)?\/\//.test(deployUrl || '')) {
|
|
22
|
+
// If baseHref or deployUrl is absolute, unsupported by nx serve
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// normalize baseHref
|
|
26
|
+
// for nx serve the starting base is always `/` so a relative
|
|
27
|
+
// and root relative value are identical
|
|
28
|
+
const baseHrefParts = (baseHref || '')
|
|
29
|
+
.split('/')
|
|
30
|
+
.filter((part) => part !== '');
|
|
31
|
+
if (baseHref && !baseHref.endsWith('/')) {
|
|
32
|
+
baseHrefParts.pop();
|
|
33
|
+
}
|
|
34
|
+
const normalizedBaseHref = baseHrefParts.length === 0 ? '/' : `/${baseHrefParts.join('/')}/`;
|
|
35
|
+
if (deployUrl && deployUrl[0] === '/') {
|
|
36
|
+
if (baseHref && baseHref[0] === '/' && normalizedBaseHref !== deployUrl) {
|
|
37
|
+
// If baseHref and deployUrl are root relative and not equivalent, unsupported by nx serve
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return deployUrl;
|
|
41
|
+
}
|
|
42
|
+
// Join together baseHref and deployUrl
|
|
43
|
+
return `${normalizedBaseHref}${deployUrl || ''}`;
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface WebDevServerOptions {
|
|
2
|
+
host?: string;
|
|
3
|
+
port?: number;
|
|
4
|
+
publicHost?: string;
|
|
5
|
+
ssl?: boolean;
|
|
6
|
+
sslKey?: string;
|
|
7
|
+
sslCert?: string;
|
|
8
|
+
proxyConfig?: string;
|
|
9
|
+
buildTarget: string;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
liveReload?: boolean;
|
|
12
|
+
hmr?: boolean;
|
|
13
|
+
watch?: boolean;
|
|
14
|
+
allowedHosts?: string;
|
|
15
|
+
memoryLimit?: number;
|
|
16
|
+
baseHref?: string;
|
|
17
|
+
}
|