@nx/web 17.0.5 → 17.0.6
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 +1 -1
- package/README.md +4 -9
- package/migrations.json +1 -11
- package/package.json +4 -4
- package/src/executors/file-server/file-server.impl.js +30 -67
- package/src/executors/file-server/schema.d.ts +4 -4
- package/src/executors/file-server/schema.json +3 -2
- package/src/generators/application/application.js +46 -128
- package/src/generators/application/files/app-vite/src/app/app.element.__style__ +1 -9
- package/src/generators/application/files/app-vite/src/app/app.element.ts__tmpl__ +5 -39
- package/src/generators/application/files/app-webpack/src/app/app.element.__style__ +1 -9
- package/src/generators/application/files/app-webpack/src/app/app.element.ts__tmpl__ +5 -39
- package/src/generators/application/files/app-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/app-webpack/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/app-webpack/webpack.config.js__tmpl__ +5 -36
- package/src/generators/application/schema.d.ts +0 -1
- package/src/generators/application/schema.json +3 -3
- package/src/generators/init/init.js +40 -7
- package/src/generators/init/schema.d.ts +3 -1
- package/src/generators/init/schema.json +20 -7
- package/src/generators/static-serve/schema.json +1 -6
- package/src/generators/static-serve/static-serve-configuration.d.ts +2 -3
- package/src/generators/static-serve/static-serve-configuration.js +5 -14
- package/src/migrations/update-15-9-1/add-dropped-dependencies.js +2 -2
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/utils/wait-for-port-open.js +2 -10
- package/src/utils/has-webpack-plugin.d.ts +0 -2
- package/src/utils/has-webpack-plugin.js +0 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
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>
|
|
1
|
+
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
|
|
7
2
|
|
|
8
3
|
<div style="text-align: center;">
|
|
9
4
|
|
|
@@ -20,9 +15,9 @@
|
|
|
20
15
|
|
|
21
16
|
<hr>
|
|
22
17
|
|
|
23
|
-
# Nx: Smart
|
|
18
|
+
# Nx: Smart, Fast and Extensible Build System
|
|
24
19
|
|
|
25
|
-
Nx is a build system with
|
|
20
|
+
Nx is a next generation build system with first class monorepo support and powerful integrations.
|
|
26
21
|
|
|
27
22
|
This package is a [Web plugin for Nx](https://nx.dev/packages/web).
|
|
28
23
|
|
|
@@ -64,5 +59,5 @@ npx nx@latest init
|
|
|
64
59
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
65
60
|
|
|
66
61
|
<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
|
|
62
|
+
width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
|
|
68
63
|
|
package/migrations.json
CHANGED
|
@@ -37,15 +37,5 @@
|
|
|
37
37
|
"implementation": "./src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"packageJsonUpdates": {
|
|
41
|
-
"17.3.0": {
|
|
42
|
-
"version": "17.3.0-beta.3",
|
|
43
|
-
"packages": {
|
|
44
|
-
"@types/node": {
|
|
45
|
-
"version": "18.16.9",
|
|
46
|
-
"alwaysAddToPackageJson": false
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
40
|
+
"packageJsonUpdates": {}
|
|
51
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "v17.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Web Components contains generators for managing Web Component applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n\n- Scaffolding for creating buildable libraries that can be published to npm.\n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"detect-port": "^1.5.1",
|
|
35
35
|
"http-server": "^14.1.0",
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/devkit": "
|
|
38
|
-
"@nx/js": "
|
|
39
|
-
"@nrwl/web": "
|
|
37
|
+
"@nx/devkit": "v17.0.6",
|
|
38
|
+
"@nx/js": "v17.0.6",
|
|
39
|
+
"@nrwl/web": "v17.0.6"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -9,7 +9,6 @@ const path_1 = require("path");
|
|
|
9
9
|
const package_json_1 = require("nx/src/utils/package-json");
|
|
10
10
|
const detectPort = require("detect-port");
|
|
11
11
|
const client_1 = require("nx/src/daemon/client/client");
|
|
12
|
-
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
13
12
|
// platform specific command name
|
|
14
13
|
const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
|
|
15
14
|
function getHttpServerArgs(options) {
|
|
@@ -45,15 +44,8 @@ function getHttpServerArgs(options) {
|
|
|
45
44
|
}
|
|
46
45
|
return args;
|
|
47
46
|
}
|
|
48
|
-
function getBuildTargetCommand(options
|
|
49
|
-
const
|
|
50
|
-
const cmd = ['nx', 'run'];
|
|
51
|
-
if (target.configuration) {
|
|
52
|
-
cmd.push(`${target.project}:${target.target}:${target.configuration}`);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
cmd.push(`${target.project}:${target.target}`);
|
|
56
|
-
}
|
|
47
|
+
function getBuildTargetCommand(options) {
|
|
48
|
+
const cmd = ['nx', 'run', options.buildTarget];
|
|
57
49
|
if (options.parallel) {
|
|
58
50
|
cmd.push(`--parallel`);
|
|
59
51
|
}
|
|
@@ -66,27 +58,16 @@ function getBuildTargetOutputPath(options, context) {
|
|
|
66
58
|
if (options.staticFilePath) {
|
|
67
59
|
return options.staticFilePath;
|
|
68
60
|
}
|
|
69
|
-
let
|
|
61
|
+
let buildOptions;
|
|
70
62
|
try {
|
|
71
63
|
const target = (0, devkit_1.parseTargetString)(options.buildTarget, context);
|
|
72
|
-
|
|
73
|
-
if (buildOptions?.outputPath) {
|
|
74
|
-
outputPath = buildOptions.outputPath;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
const project = context.projectGraph.nodes[context.projectName];
|
|
78
|
-
const buildTarget = project.data.targets[target.target];
|
|
79
|
-
outputPath = buildTarget.outputs?.[0];
|
|
80
|
-
if (outputPath)
|
|
81
|
-
outputPath = (0, utils_1.interpolate)(outputPath, {
|
|
82
|
-
projectName: project.data.name,
|
|
83
|
-
projectRoot: project.data.root,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
64
|
+
buildOptions = (0, devkit_1.readTargetOptions)(target, context);
|
|
86
65
|
}
|
|
87
66
|
catch (e) {
|
|
88
67
|
throw new Error(`Invalid buildTarget: ${options.buildTarget}`);
|
|
89
68
|
}
|
|
69
|
+
// TODO: vsavkin we should also check outputs
|
|
70
|
+
const outputPath = buildOptions.outputPath;
|
|
90
71
|
if (!outputPath) {
|
|
91
72
|
throw new Error(`Unable to get the outputPath from buildTarget ${options.buildTarget}. Make sure ${options.buildTarget} has an outputPath property or manually provide an staticFilePath property`);
|
|
92
73
|
}
|
|
@@ -97,69 +78,50 @@ function createFileWatcher(project, changeHandler) {
|
|
|
97
78
|
watchProjects: project ? [project] : 'all',
|
|
98
79
|
includeGlobalWorkspaceFiles: true,
|
|
99
80
|
includeDependentProjects: true,
|
|
100
|
-
}, async (error,
|
|
81
|
+
}, async (error, { changedFiles }) => {
|
|
101
82
|
if (error === 'closed') {
|
|
102
83
|
throw new Error('Watch error: Daemon closed the connection');
|
|
103
84
|
}
|
|
104
85
|
else if (error) {
|
|
105
86
|
throw new Error(`Watch error: ${error?.message ?? 'Unknown'}`);
|
|
106
87
|
}
|
|
107
|
-
else if (
|
|
88
|
+
else if (changedFiles.length > 0) {
|
|
108
89
|
changeHandler();
|
|
109
90
|
}
|
|
110
91
|
});
|
|
111
92
|
}
|
|
112
93
|
async function* fileServerExecutor(options, context) {
|
|
113
|
-
if (!options.buildTarget && !options.staticFilePath) {
|
|
114
|
-
throw new Error("You must set either 'buildTarget' or 'staticFilePath'.");
|
|
115
|
-
}
|
|
116
|
-
if (options.watch && !options.buildTarget) {
|
|
117
|
-
throw new Error("Watch error: You can only specify 'watch' when 'buildTarget' is set.");
|
|
118
|
-
}
|
|
119
94
|
let running = false;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
stdio: [0, 1, 2],
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
catch {
|
|
138
|
-
throw new Error(`Build target failed: ${chalk.bold(options.buildTarget)}`);
|
|
139
|
-
}
|
|
140
|
-
finally {
|
|
141
|
-
process.env.NX_SERVE_STATIC_BUILD_RUNNING = undefined;
|
|
142
|
-
running = false;
|
|
143
|
-
}
|
|
95
|
+
const run = () => {
|
|
96
|
+
if (!running) {
|
|
97
|
+
running = true;
|
|
98
|
+
try {
|
|
99
|
+
const args = getBuildTargetCommand(options);
|
|
100
|
+
(0, child_process_1.execFileSync)(pmCmd, args, {
|
|
101
|
+
stdio: [0, 1, 2],
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
throw new Error(`Build target failed: ${chalk.bold(options.buildTarget)}`);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
running = false;
|
|
144
109
|
}
|
|
145
|
-
};
|
|
146
|
-
if (options.watch) {
|
|
147
|
-
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
148
|
-
disposeWatch = await createFileWatcher(context.projectName, run);
|
|
149
110
|
}
|
|
150
|
-
|
|
151
|
-
|
|
111
|
+
};
|
|
112
|
+
let disposeWatch;
|
|
113
|
+
if (options.watch) {
|
|
114
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
115
|
+
disposeWatch = await createFileWatcher(context.projectName, run);
|
|
152
116
|
}
|
|
153
|
-
|
|
117
|
+
// perform initial run
|
|
118
|
+
run();
|
|
154
119
|
const outputPath = getBuildTargetOutputPath(options, context);
|
|
155
120
|
if (options.spa) {
|
|
156
121
|
const src = (0, path_1.join)(outputPath, 'index.html');
|
|
157
122
|
const dst = (0, path_1.join)(outputPath, '404.html');
|
|
158
123
|
// See: https://github.com/http-party/http-server#magic-files
|
|
159
124
|
(0, fs_1.copyFileSync)(src, dst);
|
|
160
|
-
// We also need to ensure the proxyUrl is set, otherwise the browser will continue to throw a 404 error
|
|
161
|
-
// This can cause unexpected behaviors and failures especially in automated test suites
|
|
162
|
-
options.proxyUrl ??= `http${options.ssl ? 's' : ''}://localhost:${port}?`;
|
|
163
125
|
}
|
|
164
126
|
const args = getHttpServerArgs(options);
|
|
165
127
|
const { path: pathToHttpServerPkgJson, packageJson } = (0, package_json_1.readModulePackageJson)('http-server', module.paths);
|
|
@@ -167,6 +129,7 @@ async function* fileServerExecutor(options, context) {
|
|
|
167
129
|
const pathToHttpServer = (0, path_1.resolve)(pathToHttpServerPkgJson.replace('package.json', ''), pathToHttpServerBin);
|
|
168
130
|
// detect port as close to when used to prevent port being used by another process
|
|
169
131
|
// when running in parallel
|
|
132
|
+
const port = await detectPort(options.port || 8080);
|
|
170
133
|
args.push(`-p=${port}`);
|
|
171
134
|
const serve = (0, child_process_1.fork)(pathToHttpServer, [outputPath, ...args], {
|
|
172
135
|
stdio: 'pipe',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export interface Schema {
|
|
2
|
-
host
|
|
3
|
-
port
|
|
4
|
-
ssl
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
ssl: boolean;
|
|
5
5
|
sslKey?: string;
|
|
6
6
|
sslCert?: string;
|
|
7
7
|
proxyUrl?: string;
|
|
8
|
-
buildTarget
|
|
8
|
+
buildTarget: string;
|
|
9
9
|
parallel: boolean;
|
|
10
10
|
maxParallel?: number;
|
|
11
11
|
withDeps: boolean;
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"proxyUrl": {
|
|
46
46
|
"type": "string",
|
|
47
|
-
"description": "URL to proxy unhandled requests to.
|
|
47
|
+
"description": "URL to proxy unhandled requests to."
|
|
48
48
|
},
|
|
49
49
|
"proxyOptions": {
|
|
50
50
|
"type": "object",
|
|
@@ -94,5 +94,6 @@
|
|
|
94
94
|
"default": -1
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
"additionalProperties": false
|
|
97
|
+
"additionalProperties": false,
|
|
98
|
+
"required": ["buildTarget"]
|
|
98
99
|
}
|
|
@@ -9,45 +9,16 @@ const path_1 = require("path");
|
|
|
9
9
|
const versions_2 = require("../../utils/versions");
|
|
10
10
|
const init_1 = require("../init/init");
|
|
11
11
|
const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
|
|
12
|
-
const has_webpack_plugin_1 = require("../../utils/has-webpack-plugin");
|
|
13
|
-
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
14
|
-
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
15
12
|
function createApplicationFiles(tree, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
else {
|
|
26
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-webpack'), options.appProjectRoot, {
|
|
27
|
-
...options,
|
|
28
|
-
...(0, devkit_1.names)(options.name),
|
|
29
|
-
tmpl: '',
|
|
30
|
-
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
31
|
-
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
32
|
-
webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
|
|
33
|
-
? {
|
|
34
|
-
compiler: options.compiler,
|
|
35
|
-
target: 'web',
|
|
36
|
-
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot != '.'
|
|
37
|
-
? options.appProjectRoot
|
|
38
|
-
: options.projectName),
|
|
39
|
-
tsConfig: './tsconfig.app.json',
|
|
40
|
-
main: './src/main.ts',
|
|
41
|
-
assets: ['./src/favicon.ico', './src/assets'],
|
|
42
|
-
index: './src/index.html',
|
|
43
|
-
baseHref: '/',
|
|
44
|
-
styles: [`./src/styles.${options.style}`],
|
|
45
|
-
}
|
|
46
|
-
: null,
|
|
47
|
-
});
|
|
48
|
-
if (options.unitTestRunner === 'none') {
|
|
49
|
-
tree.delete((0, path_1.join)(options.appProjectRoot, './src/app/app.element.spec.ts'));
|
|
50
|
-
}
|
|
13
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, options.bundler === 'vite' ? './files/app-vite' : './files/app-webpack'), options.appProjectRoot, {
|
|
14
|
+
...options,
|
|
15
|
+
...(0, devkit_1.names)(options.name),
|
|
16
|
+
tmpl: '',
|
|
17
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
18
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
19
|
+
});
|
|
20
|
+
if (options.unitTestRunner === 'none') {
|
|
21
|
+
tree.delete((0, path_1.join)(options.appProjectRoot, './src/app/app.element.spec.ts'));
|
|
51
22
|
}
|
|
52
23
|
}
|
|
53
24
|
async function setupBundler(tree, options) {
|
|
@@ -60,7 +31,6 @@ async function setupBundler(tree, options) {
|
|
|
60
31
|
if (options.bundler === 'webpack') {
|
|
61
32
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_2.nxVersion);
|
|
62
33
|
await configurationGenerator(tree, {
|
|
63
|
-
target: 'web',
|
|
64
34
|
project: options.projectName,
|
|
65
35
|
main,
|
|
66
36
|
tsConfig,
|
|
@@ -68,42 +38,38 @@ async function setupBundler(tree, options) {
|
|
|
68
38
|
devServer: true,
|
|
69
39
|
webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
|
|
70
40
|
skipFormat: true,
|
|
71
|
-
addPlugin: options.addPlugin,
|
|
72
41
|
});
|
|
73
42
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
|
|
101
|
-
}
|
|
102
|
-
// TODO(jack): Flush this out... no bundler should be possible for web but the experience isn't holistic due to missing features (e.g. writing index.html).
|
|
43
|
+
const prodConfig = project.targets.build.configurations.production;
|
|
44
|
+
const buildOptions = project.targets.build.options;
|
|
45
|
+
buildOptions.assets = assets;
|
|
46
|
+
buildOptions.index = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html');
|
|
47
|
+
buildOptions.baseHref = '/';
|
|
48
|
+
buildOptions.styles = [
|
|
49
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
|
|
50
|
+
];
|
|
51
|
+
// We can delete that, because this projest is an application
|
|
52
|
+
// and applications have a .babelrc file in their root dir.
|
|
53
|
+
// So Nx will find it and use it
|
|
54
|
+
delete buildOptions.babelUpwardRootMode;
|
|
55
|
+
buildOptions.scripts = [];
|
|
56
|
+
prodConfig.fileReplacements = [
|
|
57
|
+
{
|
|
58
|
+
replace: (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/environments/environment.ts`),
|
|
59
|
+
with: (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/environments/environment.prod.ts`),
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
prodConfig.optimization = true;
|
|
63
|
+
prodConfig.outputHashing = 'all';
|
|
64
|
+
prodConfig.sourceMap = false;
|
|
65
|
+
prodConfig.namedChunks = false;
|
|
66
|
+
prodConfig.extractLicenses = true;
|
|
67
|
+
prodConfig.vendorChunk = false;
|
|
68
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
|
|
103
69
|
}
|
|
104
70
|
else if (options.bundler === 'none') {
|
|
71
|
+
// TODO(jack): Flush this out... no bundler should be possible for web but the experience isn't holistic due to missing features (e.g. writing index.html).
|
|
105
72
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
106
|
-
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, `@nx/js:${options.compiler}`);
|
|
107
73
|
project.targets.build = {
|
|
108
74
|
executor: `@nx/js:${options.compiler}`,
|
|
109
75
|
outputs: ['{options.outputPath}'],
|
|
@@ -111,6 +77,7 @@ async function setupBundler(tree, options) {
|
|
|
111
77
|
main,
|
|
112
78
|
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot),
|
|
113
79
|
tsConfig,
|
|
80
|
+
assets,
|
|
114
81
|
},
|
|
115
82
|
};
|
|
116
83
|
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
|
|
@@ -128,6 +95,9 @@ async function addProject(tree, options) {
|
|
|
128
95
|
tags: options.parsedTags,
|
|
129
96
|
targets,
|
|
130
97
|
}, options.standaloneConfig);
|
|
98
|
+
if (options.bundler !== 'vite') {
|
|
99
|
+
await setupBundler(tree, options);
|
|
100
|
+
}
|
|
131
101
|
}
|
|
132
102
|
function setDefaults(tree, options) {
|
|
133
103
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -143,7 +113,6 @@ function setDefaults(tree, options) {
|
|
|
143
113
|
}
|
|
144
114
|
async function applicationGenerator(host, schema) {
|
|
145
115
|
return await applicationGeneratorInternal(host, {
|
|
146
|
-
addPlugin: false,
|
|
147
116
|
projectNameAndRootFormat: 'derived',
|
|
148
117
|
...schema,
|
|
149
118
|
});
|
|
@@ -152,21 +121,13 @@ exports.applicationGenerator = applicationGenerator;
|
|
|
152
121
|
async function applicationGeneratorInternal(host, schema) {
|
|
153
122
|
const options = await normalizeOptions(host, schema);
|
|
154
123
|
const tasks = [];
|
|
155
|
-
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
156
|
-
js: false,
|
|
157
|
-
skipFormat: true,
|
|
158
|
-
});
|
|
159
|
-
tasks.push(jsInitTask);
|
|
160
124
|
const webTask = await (0, init_1.webInitGenerator)(host, {
|
|
161
125
|
...options,
|
|
162
126
|
skipFormat: true,
|
|
163
127
|
});
|
|
164
128
|
tasks.push(webTask);
|
|
165
|
-
await addProject(host, options);
|
|
166
|
-
if (options.bundler !== 'vite') {
|
|
167
|
-
await setupBundler(host, options);
|
|
168
|
-
}
|
|
169
129
|
createApplicationFiles(host, options);
|
|
130
|
+
await addProject(host, options);
|
|
170
131
|
if (options.bundler === 'vite') {
|
|
171
132
|
const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_2.nxVersion);
|
|
172
133
|
// We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
|
|
@@ -181,7 +142,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
181
142
|
includeVitest: options.unitTestRunner === 'vitest',
|
|
182
143
|
inSourceTests: options.inSourceTests,
|
|
183
144
|
skipFormat: true,
|
|
184
|
-
addPlugin: options.addPlugin,
|
|
185
145
|
});
|
|
186
146
|
tasks.push(viteTask);
|
|
187
147
|
createOrEditViteConfig(host, {
|
|
@@ -196,10 +156,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
196
156
|
const vitestTask = await vitestGenerator(host, {
|
|
197
157
|
uiFramework: 'none',
|
|
198
158
|
project: options.projectName,
|
|
199
|
-
coverageProvider: '
|
|
159
|
+
coverageProvider: 'c8',
|
|
200
160
|
inSourceTests: options.inSourceTests,
|
|
201
161
|
skipFormat: true,
|
|
202
|
-
addPlugin: options.addPlugin,
|
|
203
162
|
});
|
|
204
163
|
tasks.push(vitestTask);
|
|
205
164
|
createOrEditViteConfig(host, {
|
|
@@ -222,9 +181,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
222
181
|
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
223
182
|
],
|
|
224
183
|
unitTestRunner: options.unitTestRunner,
|
|
184
|
+
eslintFilePatterns: [`${options.appProjectRoot}/**/*.ts`],
|
|
225
185
|
skipFormat: true,
|
|
226
186
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
227
|
-
addPlugin: options.addPlugin,
|
|
228
187
|
});
|
|
229
188
|
tasks.push(lintTask);
|
|
230
189
|
}
|
|
@@ -241,8 +200,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
241
200
|
const cypressTask = await configurationGenerator(host, {
|
|
242
201
|
...options,
|
|
243
202
|
project: options.e2eProjectName,
|
|
244
|
-
devServerTarget: `${options.projectName}
|
|
245
|
-
baseUrl: options.e2eWebServerAddress,
|
|
203
|
+
devServerTarget: `${options.projectName}:serve`,
|
|
246
204
|
directory: 'src',
|
|
247
205
|
skipFormat: true,
|
|
248
206
|
});
|
|
@@ -265,9 +223,8 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
265
223
|
js: false,
|
|
266
224
|
linter: options.linter,
|
|
267
225
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
268
|
-
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx
|
|
269
|
-
webServerAddress:
|
|
270
|
-
addPlugin: options.addPlugin,
|
|
226
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
|
|
227
|
+
webServerAddress: 'http://localhost:4200',
|
|
271
228
|
});
|
|
272
229
|
tasks.push(playwrightTask);
|
|
273
230
|
}
|
|
@@ -279,7 +236,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
279
236
|
setupFile: 'web-components',
|
|
280
237
|
compiler: options.compiler,
|
|
281
238
|
skipFormat: true,
|
|
282
|
-
addPlugin: options.addPlugin,
|
|
283
239
|
});
|
|
284
240
|
tasks.push(jestTask);
|
|
285
241
|
}
|
|
@@ -301,13 +257,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
301
257
|
});
|
|
302
258
|
}
|
|
303
259
|
setDefaults(host, options);
|
|
304
|
-
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, { '@types/node': versions_2.typesNodeVersion }));
|
|
305
260
|
if (!schema.skipFormat) {
|
|
306
261
|
await (0, devkit_1.formatFiles)(host);
|
|
307
262
|
}
|
|
308
|
-
tasks.push(() => {
|
|
309
|
-
(0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
|
|
310
|
-
});
|
|
311
263
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
312
264
|
}
|
|
313
265
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
@@ -320,39 +272,8 @@ async function normalizeOptions(host, options) {
|
|
|
320
272
|
callingGenerator: '@nx/web:application',
|
|
321
273
|
});
|
|
322
274
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
323
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
324
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
325
|
-
nxJson.useInferencePlugins !== false;
|
|
326
|
-
options.addPlugin ??= addPluginDefault;
|
|
327
|
-
let e2eWebServerTarget = 'serve';
|
|
328
|
-
if (options.addPlugin) {
|
|
329
|
-
if (nxJson.plugins) {
|
|
330
|
-
for (const plugin of nxJson.plugins) {
|
|
331
|
-
if (options.bundler === 'vite' &&
|
|
332
|
-
typeof plugin === 'object' &&
|
|
333
|
-
plugin.plugin === '@nx/vite/plugin' &&
|
|
334
|
-
plugin.options.serveTargetName) {
|
|
335
|
-
e2eWebServerTarget = plugin.options
|
|
336
|
-
.serveTargetName;
|
|
337
|
-
}
|
|
338
|
-
else if (options.bundler === 'webpack' &&
|
|
339
|
-
typeof plugin === 'object' &&
|
|
340
|
-
plugin.plugin === '@nx/webpack/plugin' &&
|
|
341
|
-
plugin.options.serveTargetName) {
|
|
342
|
-
e2eWebServerTarget = plugin.options
|
|
343
|
-
.serveTargetName;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
let e2ePort = 4200;
|
|
349
|
-
if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
|
|
350
|
-
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
|
|
351
|
-
e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
|
|
352
|
-
}
|
|
353
275
|
const e2eProjectName = `${appProjectName}-e2e`;
|
|
354
276
|
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
355
|
-
const e2eWebServerAddress = `http://localhost:${e2ePort}`;
|
|
356
277
|
const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
|
|
357
278
|
const parsedTags = options.tags
|
|
358
279
|
? options.tags.split(',').map((s) => s.trim())
|
|
@@ -374,9 +295,6 @@ async function normalizeOptions(host, options) {
|
|
|
374
295
|
appProjectRoot,
|
|
375
296
|
e2eProjectRoot,
|
|
376
297
|
e2eProjectName,
|
|
377
|
-
e2eWebServerAddress,
|
|
378
|
-
e2eWebServerTarget,
|
|
379
|
-
e2ePort,
|
|
380
298
|
parsedTags,
|
|
381
299
|
};
|
|
382
300
|
}
|
|
@@ -278,15 +278,7 @@
|
|
|
278
278
|
#nx-console svg {
|
|
279
279
|
color: rgba(0, 122, 204, 1);
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
margin-top: 2rem;
|
|
283
|
-
}
|
|
284
|
-
#nx-console-jetbrains:hover {
|
|
285
|
-
background-color: rgba(255, 49, 140, 1);
|
|
286
|
-
}
|
|
287
|
-
#nx-console-jetbrains svg {
|
|
288
|
-
color: rgba(255, 49, 140, 1);
|
|
289
|
-
}
|
|
281
|
+
|
|
290
282
|
#nx-repo:hover {
|
|
291
283
|
background-color: rgba(24, 23, 23, 1);
|
|
292
284
|
}
|
|
@@ -234,44 +234,10 @@ export class AppElement extends HTMLElement {
|
|
|
234
234
|
/>
|
|
235
235
|
</svg>
|
|
236
236
|
<span>
|
|
237
|
-
Install Nx Console
|
|
238
|
-
<span>
|
|
237
|
+
Install Nx Console
|
|
238
|
+
<span>Plugin for VSCode</span>
|
|
239
239
|
</span>
|
|
240
240
|
</a>
|
|
241
|
-
<a
|
|
242
|
-
id="nx-console-jetbrains"
|
|
243
|
-
class="button-pill rounded shadow"
|
|
244
|
-
href="https://plugins.jetbrains.com/plugin/21060-nx-console"
|
|
245
|
-
target="_blank"
|
|
246
|
-
rel="noreferrer"
|
|
247
|
-
>
|
|
248
|
-
<svg
|
|
249
|
-
height="48"
|
|
250
|
-
width="48"
|
|
251
|
-
viewBox="20 20 60 60"
|
|
252
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
253
|
-
>
|
|
254
|
-
<path d="m22.5 22.5h60v60h-60z" />
|
|
255
|
-
<g fill="#fff">
|
|
256
|
-
<path d="m29.03 71.25h22.5v3.75h-22.5z" />
|
|
257
|
-
<path d="m28.09 38 1.67-1.58a1.88 1.88 0 0 0 1.47.87c.64 0 1.06-.44 1.06-1.31v-5.98h2.58v6a3.48 3.48 0 0 1 -.87 2.6 3.56 3.56 0 0 1 -2.57.95 3.84 3.84 0 0 1 -3.34-1.55z" />
|
|
258
|
-
<path d="m36 30h7.53v2.19h-5v1.44h4.49v2h-4.42v1.49h5v2.21h-7.6z" />
|
|
259
|
-
<path d="m47.23 32.29h-2.8v-2.29h8.21v2.27h-2.81v7.1h-2.6z" />
|
|
260
|
-
<path d="m29.13 43.08h4.42a3.53 3.53 0 0 1 2.55.83 2.09 2.09 0 0 1 .6 1.53 2.16 2.16 0 0 1 -1.44 2.09 2.27 2.27 0 0 1 1.86 2.29c0 1.61-1.31 2.59-3.55 2.59h-4.44zm5 2.89c0-.52-.42-.8-1.18-.8h-1.29v1.64h1.24c.79 0 1.25-.26 1.25-.81zm-.9 2.66h-1.57v1.73h1.62c.8 0 1.24-.31 1.24-.86 0-.5-.4-.87-1.27-.87z" />
|
|
261
|
-
<path d="m38 43.08h4.1a4.19 4.19 0 0 1 3 1 2.93 2.93 0 0 1 .9 2.19 3 3 0 0 1 -1.93 2.89l2.24 3.27h-3l-1.88-2.84h-.87v2.84h-2.56zm4 4.5c.87 0 1.39-.43 1.39-1.11 0-.75-.54-1.12-1.4-1.12h-1.44v2.26z" />
|
|
262
|
-
<path d="m49.59 43h2.5l4 9.44h-2.79l-.67-1.69h-3.63l-.67 1.69h-2.71zm2.27 5.73-1-2.65-1.06 2.65z" />
|
|
263
|
-
<path d="m56.46 43.05h2.6v9.37h-2.6z" />
|
|
264
|
-
<path d="m60.06 43.05h2.42l3.37 5v-5h2.57v9.37h-2.26l-3.53-5.14v5.14h-2.57z" />
|
|
265
|
-
<path d="m68.86 51 1.45-1.73a4.84 4.84 0 0 0 3 1.13c.71 0 1.08-.24 1.08-.65 0-.4-.31-.6-1.59-.91-2-.46-3.53-1-3.53-2.93 0-1.74 1.37-3 3.62-3a5.89 5.89 0 0 1 3.86 1.25l-1.26 1.84a4.63 4.63 0 0 0 -2.62-.92c-.63 0-.94.25-.94.6 0 .42.32.61 1.63.91 2.14.46 3.44 1.16 3.44 2.91 0 1.91-1.51 3-3.79 3a6.58 6.58 0 0 1 -4.35-1.5z" />
|
|
266
|
-
</g>
|
|
267
|
-
</svg>
|
|
268
|
-
<span>
|
|
269
|
-
Install Nx Console for JetBrains
|
|
270
|
-
<span>
|
|
271
|
-
Available for WebStorm, Intellij IDEA Ultimate and more!
|
|
272
|
-
</span>
|
|
273
|
-
</span>
|
|
274
|
-
</a>
|
|
275
241
|
<div id="nx-cloud" class="rounded shadow">
|
|
276
242
|
<div>
|
|
277
243
|
<svg id="nx-cloud-logo" role="img" xmlns="http://www.w3.org/2000/svg" stroke="currentColor" fill="transparent" viewBox="0 0 24 24">
|
|
@@ -279,7 +245,7 @@ export class AppElement extends HTMLElement {
|
|
|
279
245
|
<path stroke-width="2" d="M23 6v14.1667C23 21.7307 21.7307 23 20.1667 23H6c0-3.128 2.53867-5.6667 5.6667-5.6667 3.128 0 5.6666-2.5386 5.6666-5.6666C17.3333 8.53867 19.872 6 23 6Z" />
|
|
280
246
|
</svg>
|
|
281
247
|
<h2>
|
|
282
|
-
|
|
248
|
+
NxCloud
|
|
283
249
|
<span>
|
|
284
250
|
Enable faster CI & better DX
|
|
285
251
|
</span>
|
|
@@ -289,7 +255,7 @@ export class AppElement extends HTMLElement {
|
|
|
289
255
|
You can activate distributed tasks executions and caching by
|
|
290
256
|
running:
|
|
291
257
|
</p>
|
|
292
|
-
<pre>nx connect</pre>
|
|
258
|
+
<pre>nx connect-to-nx-cloud</pre>
|
|
293
259
|
<a href="https://nx.app/?utm_source=nx-project" target="_blank" rel="noreferrer"> What is Nx Cloud? </a>
|
|
294
260
|
</div>
|
|
295
261
|
<a id="nx-repo" class="button-pill rounded shadow" href="https://github.com/nrwl/nx?utm_source=nx-project" target="_blank" rel="noreferrer">
|
|
@@ -336,7 +302,7 @@ export class AppElement extends HTMLElement {
|
|
|
336
302
|
nx g @nx/angular:lib ui
|
|
337
303
|
|
|
338
304
|
<span># Add a component</span>
|
|
339
|
-
nx g @nx/angular:component ui
|
|
305
|
+
nx g @nx/angular:component button --project ui</pre>
|
|
340
306
|
</details>
|
|
341
307
|
<details>
|
|
342
308
|
<summary>
|
|
@@ -278,15 +278,7 @@
|
|
|
278
278
|
#nx-console svg {
|
|
279
279
|
color: rgba(0, 122, 204, 1);
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
margin-top: 2rem;
|
|
283
|
-
}
|
|
284
|
-
#nx-console-jetbrains:hover {
|
|
285
|
-
background-color: rgba(255, 49, 140, 1);
|
|
286
|
-
}
|
|
287
|
-
#nx-console-jetbrains svg {
|
|
288
|
-
color: rgba(255, 49, 140, 1);
|
|
289
|
-
}
|
|
281
|
+
|
|
290
282
|
#nx-repo:hover {
|
|
291
283
|
background-color: rgba(24, 23, 23, 1);
|
|
292
284
|
}
|
|
@@ -234,44 +234,10 @@ export class AppElement extends HTMLElement {
|
|
|
234
234
|
/>
|
|
235
235
|
</svg>
|
|
236
236
|
<span>
|
|
237
|
-
Install Nx Console
|
|
238
|
-
<span>
|
|
237
|
+
Install Nx Console
|
|
238
|
+
<span>Plugin for VSCode</span>
|
|
239
239
|
</span>
|
|
240
240
|
</a>
|
|
241
|
-
<a
|
|
242
|
-
id="nx-console-jetbrains"
|
|
243
|
-
class="button-pill rounded shadow"
|
|
244
|
-
href="https://plugins.jetbrains.com/plugin/21060-nx-console"
|
|
245
|
-
target="_blank"
|
|
246
|
-
rel="noreferrer"
|
|
247
|
-
>
|
|
248
|
-
<svg
|
|
249
|
-
height="48"
|
|
250
|
-
width="48"
|
|
251
|
-
viewBox="20 20 60 60"
|
|
252
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
253
|
-
>
|
|
254
|
-
<path d="m22.5 22.5h60v60h-60z" />
|
|
255
|
-
<g fill="#fff">
|
|
256
|
-
<path d="m29.03 71.25h22.5v3.75h-22.5z" />
|
|
257
|
-
<path d="m28.09 38 1.67-1.58a1.88 1.88 0 0 0 1.47.87c.64 0 1.06-.44 1.06-1.31v-5.98h2.58v6a3.48 3.48 0 0 1 -.87 2.6 3.56 3.56 0 0 1 -2.57.95 3.84 3.84 0 0 1 -3.34-1.55z" />
|
|
258
|
-
<path d="m36 30h7.53v2.19h-5v1.44h4.49v2h-4.42v1.49h5v2.21h-7.6z" />
|
|
259
|
-
<path d="m47.23 32.29h-2.8v-2.29h8.21v2.27h-2.81v7.1h-2.6z" />
|
|
260
|
-
<path d="m29.13 43.08h4.42a3.53 3.53 0 0 1 2.55.83 2.09 2.09 0 0 1 .6 1.53 2.16 2.16 0 0 1 -1.44 2.09 2.27 2.27 0 0 1 1.86 2.29c0 1.61-1.31 2.59-3.55 2.59h-4.44zm5 2.89c0-.52-.42-.8-1.18-.8h-1.29v1.64h1.24c.79 0 1.25-.26 1.25-.81zm-.9 2.66h-1.57v1.73h1.62c.8 0 1.24-.31 1.24-.86 0-.5-.4-.87-1.27-.87z" />
|
|
261
|
-
<path d="m38 43.08h4.1a4.19 4.19 0 0 1 3 1 2.93 2.93 0 0 1 .9 2.19 3 3 0 0 1 -1.93 2.89l2.24 3.27h-3l-1.88-2.84h-.87v2.84h-2.56zm4 4.5c.87 0 1.39-.43 1.39-1.11 0-.75-.54-1.12-1.4-1.12h-1.44v2.26z" />
|
|
262
|
-
<path d="m49.59 43h2.5l4 9.44h-2.79l-.67-1.69h-3.63l-.67 1.69h-2.71zm2.27 5.73-1-2.65-1.06 2.65z" />
|
|
263
|
-
<path d="m56.46 43.05h2.6v9.37h-2.6z" />
|
|
264
|
-
<path d="m60.06 43.05h2.42l3.37 5v-5h2.57v9.37h-2.26l-3.53-5.14v5.14h-2.57z" />
|
|
265
|
-
<path d="m68.86 51 1.45-1.73a4.84 4.84 0 0 0 3 1.13c.71 0 1.08-.24 1.08-.65 0-.4-.31-.6-1.59-.91-2-.46-3.53-1-3.53-2.93 0-1.74 1.37-3 3.62-3a5.89 5.89 0 0 1 3.86 1.25l-1.26 1.84a4.63 4.63 0 0 0 -2.62-.92c-.63 0-.94.25-.94.6 0 .42.32.61 1.63.91 2.14.46 3.44 1.16 3.44 2.91 0 1.91-1.51 3-3.79 3a6.58 6.58 0 0 1 -4.35-1.5z" />
|
|
266
|
-
</g>
|
|
267
|
-
</svg>
|
|
268
|
-
<span>
|
|
269
|
-
Install Nx Console for JetBrains
|
|
270
|
-
<span>
|
|
271
|
-
Available for WebStorm, Intellij IDEA Ultimate and more!
|
|
272
|
-
</span>
|
|
273
|
-
</span>
|
|
274
|
-
</a>
|
|
275
241
|
<div id="nx-cloud" class="rounded shadow">
|
|
276
242
|
<div>
|
|
277
243
|
<svg id="nx-cloud-logo" role="img" xmlns="http://www.w3.org/2000/svg" stroke="currentColor" fill="transparent" viewBox="0 0 24 24">
|
|
@@ -279,7 +245,7 @@ export class AppElement extends HTMLElement {
|
|
|
279
245
|
<path stroke-width="2" d="M23 6v14.1667C23 21.7307 21.7307 23 20.1667 23H6c0-3.128 2.53867-5.6667 5.6667-5.6667 3.128 0 5.6666-2.5386 5.6666-5.6666C17.3333 8.53867 19.872 6 23 6Z" />
|
|
280
246
|
</svg>
|
|
281
247
|
<h2>
|
|
282
|
-
|
|
248
|
+
NxCloud
|
|
283
249
|
<span>
|
|
284
250
|
Enable faster CI & better DX
|
|
285
251
|
</span>
|
|
@@ -289,7 +255,7 @@ export class AppElement extends HTMLElement {
|
|
|
289
255
|
You can activate distributed tasks executions and caching by
|
|
290
256
|
running:
|
|
291
257
|
</p>
|
|
292
|
-
<pre>nx connect</pre>
|
|
258
|
+
<pre>nx connect-to-nx-cloud</pre>
|
|
293
259
|
<a href="https://nx.app/?utm_source=nx-project" target="_blank" rel="noreferrer"> What is Nx Cloud? </a>
|
|
294
260
|
</div>
|
|
295
261
|
<a id="nx-repo" class="button-pill rounded shadow" href="https://github.com/nrwl/nx?utm_source=nx-project" target="_blank" rel="noreferrer">
|
|
@@ -336,7 +302,7 @@ export class AppElement extends HTMLElement {
|
|
|
336
302
|
nx g @nx/angular:lib ui
|
|
337
303
|
|
|
338
304
|
<span># Add a component</span>
|
|
339
|
-
nx g @nx/angular:component ui
|
|
305
|
+
nx g @nx/angular:component button --project ui</pre>
|
|
340
306
|
</details>
|
|
341
307
|
<details>
|
|
342
308
|
<summary>
|
|
@@ -1,39 +1,8 @@
|
|
|
1
|
-
<% if (webpackPluginOptions) { %>
|
|
2
|
-
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
3
|
-
const { join } = require('path');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
output: {
|
|
7
|
-
path: join(__dirname, '<%= offsetFromRoot %><%= webpackPluginOptions.outputPath %>'),
|
|
8
|
-
},
|
|
9
|
-
devServer: {
|
|
10
|
-
port: 4200
|
|
11
|
-
},
|
|
12
|
-
plugins: [
|
|
13
|
-
new NxWebpackPlugin({
|
|
14
|
-
tsConfig: '<%= webpackPluginOptions.tsConfig %>',
|
|
15
|
-
compiler: '<%= webpackPluginOptions.compiler %>',
|
|
16
|
-
main: '<%= webpackPluginOptions.main %>',
|
|
17
|
-
index: '<%= webpackPluginOptions.index %>',
|
|
18
|
-
baseHref: '<%= webpackPluginOptions.baseHref %>',
|
|
19
|
-
assets: <%- JSON.stringify(webpackPluginOptions.assets) %>,
|
|
20
|
-
styles: <%- JSON.stringify(webpackPluginOptions.styles) %>,
|
|
21
|
-
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
22
|
-
optimization: process.env['NODE_ENV'] === 'production',
|
|
23
|
-
})
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
<% } else { %>
|
|
27
1
|
const { composePlugins, withNx, withWeb } = require('@nx/webpack');
|
|
28
2
|
|
|
29
3
|
// Nx plugins for webpack.
|
|
30
|
-
module.exports = composePlugins(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// e.g. `config.plugins.push(new MyPlugin())`
|
|
36
|
-
return config;
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
<% } %>
|
|
4
|
+
module.exports = composePlugins(withNx(), withWeb(), (config) => {
|
|
5
|
+
// Update the webpack config as needed here.
|
|
6
|
+
// e.g. `config.plugins.push(new MyPlugin())`
|
|
7
|
+
return config;
|
|
8
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxWebApp",
|
|
5
5
|
"title": "Create a Web Application for Nx",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"value": "scss",
|
|
42
|
-
"label": "SASS(.scss) [
|
|
42
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"value": "less",
|
|
46
|
-
"label": "LESS [
|
|
46
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
47
47
|
}
|
|
48
48
|
]
|
|
49
49
|
}
|
|
@@ -2,22 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webInitGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
5
6
|
const versions_1 = require("../../utils/versions");
|
|
6
7
|
function updateDependencies(tree, schema) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/web'], []);
|
|
9
|
+
const devDependencies = {
|
|
10
|
+
'@nx/web': versions_1.nxVersion,
|
|
11
|
+
'@types/node': versions_1.typesNodeVersion,
|
|
12
|
+
};
|
|
13
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
14
|
+
tslib: versions_1.tsLibVersion,
|
|
15
|
+
}, devDependencies);
|
|
11
16
|
}
|
|
12
17
|
async function webInitGenerator(tree, schema) {
|
|
13
|
-
|
|
18
|
+
const tasks = [];
|
|
19
|
+
const jsInitTask = await (0, js_1.initGenerator)(tree, {
|
|
20
|
+
js: false,
|
|
21
|
+
skipFormat: true,
|
|
22
|
+
});
|
|
23
|
+
tasks.push(jsInitTask);
|
|
24
|
+
if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
|
|
25
|
+
const { jestInitGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
26
|
+
const jestTask = await jestInitGenerator(tree, {
|
|
27
|
+
skipPackageJson: schema.skipPackageJson,
|
|
28
|
+
});
|
|
29
|
+
tasks.push(jestTask);
|
|
30
|
+
}
|
|
31
|
+
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'cypress') {
|
|
32
|
+
const { cypressInitGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
33
|
+
const cypressTask = await cypressInitGenerator(tree, {
|
|
34
|
+
skipPackageJson: schema.skipPackageJson,
|
|
35
|
+
});
|
|
36
|
+
tasks.push(cypressTask);
|
|
37
|
+
}
|
|
38
|
+
else if (schema.e2eTestRunner === 'playwright') {
|
|
39
|
+
const { initGenerator: playwrightInitGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
40
|
+
const playwrightConfigTask = await playwrightInitGenerator(tree, {
|
|
41
|
+
skipFormat: true,
|
|
42
|
+
skipPackageJson: schema.skipPackageJson,
|
|
43
|
+
});
|
|
44
|
+
tasks.push(playwrightConfigTask);
|
|
45
|
+
}
|
|
14
46
|
if (!schema.skipPackageJson) {
|
|
15
|
-
installTask = updateDependencies(tree, schema);
|
|
47
|
+
const installTask = updateDependencies(tree, schema);
|
|
48
|
+
tasks.push(installTask);
|
|
16
49
|
}
|
|
17
50
|
if (!schema.skipFormat) {
|
|
18
51
|
await (0, devkit_1.formatFiles)(tree);
|
|
19
52
|
}
|
|
20
|
-
return
|
|
53
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
21
54
|
}
|
|
22
55
|
exports.webInitGenerator = webInitGenerator;
|
|
23
56
|
exports.default = webInitGenerator;
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"$id": "NxWebInit",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"title": "Init Web Plugin",
|
|
6
6
|
"description": "Init Web Plugin.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
+
"bundler": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The bundler to use.",
|
|
12
|
+
"enum": ["webpack", "none", "vite"],
|
|
13
|
+
"default": "webpack"
|
|
14
|
+
},
|
|
15
|
+
"unitTestRunner": {
|
|
16
|
+
"description": "Adds the specified unit test runner",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["jest", "none"],
|
|
19
|
+
"default": "jest"
|
|
20
|
+
},
|
|
21
|
+
"e2eTestRunner": {
|
|
22
|
+
"description": "Adds the specified e2e test runner",
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": ["cypress", "playwright", "none"],
|
|
25
|
+
"x-prompt": "Which E2E test runner would you like to use?",
|
|
26
|
+
"default": "cypress"
|
|
27
|
+
},
|
|
9
28
|
"skipFormat": {
|
|
10
29
|
"description": "Skip formatting files",
|
|
11
30
|
"type": "boolean",
|
|
@@ -16,12 +35,6 @@
|
|
|
16
35
|
"type": "boolean",
|
|
17
36
|
"default": false,
|
|
18
37
|
"x-priority": "internal"
|
|
19
|
-
},
|
|
20
|
-
"keepExistingVersions": {
|
|
21
|
-
"type": "boolean",
|
|
22
|
-
"x-priority": "internal",
|
|
23
|
-
"description": "Keep existing dependencies versions",
|
|
24
|
-
"default": false
|
|
25
38
|
}
|
|
26
39
|
},
|
|
27
40
|
"required": []
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"$id": "NxWebStaticServe",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"title": "Static Serve Configuration",
|
|
@@ -18,11 +18,6 @@
|
|
|
18
18
|
"type": "string",
|
|
19
19
|
"description": "Name of the serve target to add. Defaults to 'serve-static'.",
|
|
20
20
|
"default": "serve-static"
|
|
21
|
-
},
|
|
22
|
-
"spa": {
|
|
23
|
-
"type": "boolean",
|
|
24
|
-
"description": "Whether to set the 'spa' flag on the generated target.",
|
|
25
|
-
"default": true
|
|
26
21
|
}
|
|
27
22
|
},
|
|
28
23
|
"required": ["buildTarget"]
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
2
|
interface WebStaticServeSchema {
|
|
3
3
|
buildTarget: string;
|
|
4
4
|
outputPath?: string;
|
|
5
5
|
targetName?: string;
|
|
6
|
-
spa?: boolean;
|
|
7
6
|
}
|
|
8
|
-
export declare function webStaticServeGenerator(tree: Tree, options: WebStaticServeSchema):
|
|
7
|
+
export declare function webStaticServeGenerator(tree: Tree, options: WebStaticServeSchema): void;
|
|
9
8
|
export default webStaticServeGenerator;
|
|
@@ -2,25 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webStaticServeGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
|
|
6
|
-
const opts =
|
|
5
|
+
function webStaticServeGenerator(tree, options) {
|
|
6
|
+
const opts = normalizeOptions(tree, options);
|
|
7
7
|
addStaticConfig(tree, opts);
|
|
8
8
|
}
|
|
9
9
|
exports.webStaticServeGenerator = webStaticServeGenerator;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
17
|
-
}
|
|
18
|
-
const target = (0, devkit_1.parseTargetString)(options.buildTarget, projectGraph);
|
|
10
|
+
function normalizeOptions(tree, options) {
|
|
11
|
+
const target = (0, devkit_1.parseTargetString)(options.buildTarget);
|
|
19
12
|
const opts = {
|
|
20
13
|
...options,
|
|
21
14
|
targetName: options.targetName || 'serve-static',
|
|
22
15
|
projectName: target.project,
|
|
23
|
-
spa: options.spa ?? true,
|
|
24
16
|
};
|
|
25
17
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, target.project);
|
|
26
18
|
const buildTargetConfig = projectConfig?.targets?.[target.target];
|
|
@@ -35,7 +27,7 @@ Optionally, you can provide a different name with the --target-name option other
|
|
|
35
27
|
}
|
|
36
28
|
// NOTE: @nx/web:file-server only looks for the outputPath option
|
|
37
29
|
if (!buildTargetConfig.options?.outputPath && !opts.outputPath) {
|
|
38
|
-
// attempt to find the
|
|
30
|
+
// attempt to find the suiteable path from the outputs
|
|
39
31
|
let maybeOutputValue;
|
|
40
32
|
for (const o of buildTargetConfig?.outputs || []) {
|
|
41
33
|
const isInterpolatedOutput = o.trim().startsWith('{options.');
|
|
@@ -73,7 +65,6 @@ function addStaticConfig(tree, opts) {
|
|
|
73
65
|
options: {
|
|
74
66
|
buildTarget: opts.buildTarget,
|
|
75
67
|
staticFilePath: opts.outputPath,
|
|
76
|
-
spa: opts.spa,
|
|
77
68
|
},
|
|
78
69
|
};
|
|
79
70
|
projectConfig.targets[opts.targetName] = staticServeOptions;
|
|
@@ -13,7 +13,7 @@ async function addDroppedDependencies(tree) {
|
|
|
13
13
|
for (const [_, projectConfiguration] of projects) {
|
|
14
14
|
for (const [_, targetConfiguration] of Object.entries(projectConfiguration.targets ?? {})) {
|
|
15
15
|
for (const droppedDependency of droppedDependencies) {
|
|
16
|
-
if (targetConfiguration
|
|
16
|
+
if (targetConfiguration.executor?.startsWith(droppedDependency + ':')) {
|
|
17
17
|
devDependencies[droppedDependency] = devkit_1.NX_VERSION;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -22,7 +22,7 @@ async function addDroppedDependencies(tree) {
|
|
|
22
22
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
23
23
|
for (const [_, targetConfiguration] of Object.entries(nxJson?.targetDefaults ?? {})) {
|
|
24
24
|
for (const droppedDependency of droppedDependencies) {
|
|
25
|
-
if (targetConfiguration
|
|
25
|
+
if (targetConfiguration.executor?.startsWith(droppedDependency + ':')) {
|
|
26
26
|
devDependencies[droppedDependency] = devkit_1.NX_VERSION;
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/utils/versions.d.ts
CHANGED
package/src/utils/versions.js
CHANGED
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tsLibVersion = exports.typesNodeVersion = exports.swcLoaderVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
5
|
exports.swcLoaderVersion = '0.1.15';
|
|
6
|
-
exports.typesNodeVersion = '18.
|
|
6
|
+
exports.typesNodeVersion = '18.7.1';
|
|
7
7
|
exports.tsLibVersion = '^2.3.0';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.waitForPortOpen = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const net = require("net");
|
|
6
5
|
function waitForPortOpen(port, options = {}) {
|
|
7
|
-
const
|
|
8
|
-
const allowedErrorCodes = ['ECONNREFUSED', 'ECONNRESET', 'ETIMEDOUT'];
|
|
6
|
+
const allowedErrorCodes = ['ECONNREFUSED', 'ECONNRESET'];
|
|
9
7
|
return new Promise((resolve, reject) => {
|
|
10
8
|
const checkPort = (retries = options.retries ?? 120) => {
|
|
11
9
|
const client = new net.Socket();
|
|
@@ -22,9 +20,6 @@ function waitForPortOpen(port, options = {}) {
|
|
|
22
20
|
});
|
|
23
21
|
client.once('error', (err) => {
|
|
24
22
|
if (retries === 0 || !allowedErrorCodes.includes(err['code'])) {
|
|
25
|
-
if (process.env['NX_VERBOSE_LOGGING'] === 'true') {
|
|
26
|
-
devkit_1.logger.info(`Error connecting on ${host}:${port}: ${err['code'] || err}`);
|
|
27
|
-
}
|
|
28
23
|
cleanupClient();
|
|
29
24
|
reject(err);
|
|
30
25
|
}
|
|
@@ -34,10 +29,7 @@ function waitForPortOpen(port, options = {}) {
|
|
|
34
29
|
});
|
|
35
30
|
// Node will use IPv6 if it is available, but this can cause issues if the server is only listening on IPv4.
|
|
36
31
|
// Hard-coding to look on 127.0.0.1 to avoid using the IPv6 loopback address "::1".
|
|
37
|
-
|
|
38
|
-
devkit_1.logger.info(`Connecting on ${host}:${port}`);
|
|
39
|
-
}
|
|
40
|
-
client.connect({ port, host });
|
|
32
|
+
client.connect({ port, host: options.host ?? '127.0.0.1' });
|
|
41
33
|
};
|
|
42
34
|
checkPort();
|
|
43
35
|
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasWebpackPlugin = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function hasWebpackPlugin(tree) {
|
|
6
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
-
return !!nxJson.plugins?.some((p) => typeof p === 'string'
|
|
8
|
-
? p === '@nx/webpack/plugin'
|
|
9
|
-
: p.plugin === '@nx/webpack/plugin');
|
|
10
|
-
}
|
|
11
|
-
exports.hasWebpackPlugin = hasWebpackPlugin;
|