@nx/web 0.0.0-pr-22179-271588f
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 +68 -0
- package/babel.d.ts +1 -0
- package/babel.js +6 -0
- package/executors.json +16 -0
- package/generators.json +25 -0
- package/index.d.ts +3 -0
- package/index.js +9 -0
- package/migrations.json +51 -0
- package/package.json +45 -0
- package/src/executors/file-server/compat.d.ts +2 -0
- package/src/executors/file-server/compat.js +5 -0
- package/src/executors/file-server/file-server.impl.d.ts +8 -0
- package/src/executors/file-server/file-server.impl.js +210 -0
- package/src/executors/file-server/schema.d.ts +20 -0
- package/src/executors/file-server/schema.json +98 -0
- package/src/generators/application/application.d.ts +5 -0
- package/src/generators/application/application.js +353 -0
- package/src/generators/application/files/app-vite/.babelrc__tmpl__ +5 -0
- package/src/generators/application/files/app-vite/index.html__tmpl__ +16 -0
- package/src/generators/application/files/app-vite/public/favicon.ico +0 -0
- package/src/generators/application/files/app-vite/src/app/app.element.__style__ +424 -0
- package/src/generators/application/files/app-vite/src/app/app.element.spec.ts__tmpl__ +21 -0
- package/src/generators/application/files/app-vite/src/app/app.element.ts__tmpl__ +409 -0
- package/src/generators/application/files/app-vite/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/app-vite/src/main.ts__tmpl__ +1 -0
- package/src/generators/application/files/app-vite/src/styles.__style__ +1 -0
- package/src/generators/application/files/app-vite/tsconfig.app.json +9 -0
- package/src/generators/application/files/app-vite/tsconfig.json__tmpl__ +27 -0
- package/src/generators/application/files/app-webpack/src/app/app.element.__style__ +424 -0
- package/src/generators/application/files/app-webpack/src/app/app.element.spec.ts__tmpl__ +21 -0
- package/src/generators/application/files/app-webpack/src/app/app.element.ts__tmpl__ +409 -0
- package/src/generators/application/files/app-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/app-webpack/src/favicon.ico +0 -0
- package/src/generators/application/files/app-webpack/src/index.html +14 -0
- package/src/generators/application/files/app-webpack/src/main.ts__tmpl__ +1 -0
- package/src/generators/application/files/app-webpack/src/styles.__style__ +1 -0
- package/src/generators/application/files/app-webpack/tsconfig.app.json +9 -0
- package/src/generators/application/files/app-webpack/tsconfig.json +10 -0
- package/src/generators/application/files/app-webpack/webpack.config.js__tmpl__ +39 -0
- package/src/generators/application/schema.d.ts +21 -0
- package/src/generators/application/schema.json +113 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +23 -0
- package/src/generators/init/schema.d.ts +5 -0
- package/src/generators/init/schema.json +28 -0
- package/src/generators/static-serve/schema.json +24 -0
- package/src/generators/static-serve/static-serve-configuration.d.ts +8 -0
- package/src/generators/static-serve/static-serve-configuration.js +73 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.js +9 -0
- package/src/migrations/update-15-0-0/update-rollup-executor.d.ts +2 -0
- package/src/migrations/update-15-0-0/update-rollup-executor.js +33 -0
- package/src/migrations/update-15-5-4/update-babel-preset.d.ts +2 -0
- package/src/migrations/update-15-5-4/update-babel-preset.js +32 -0
- package/src/migrations/update-15-9-1/add-dropped-dependencies.d.ts +2 -0
- package/src/migrations/update-15-9-1/add-dropped-dependencies.js +35 -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-16-0-0-update-executors/update-16-0-0-update-executors.d.ts +2 -0
- package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.js +34 -0
- package/src/plugins/webpack-nx-build-coordination-plugin.d.ts +1 -0
- package/src/plugins/webpack-nx-build-coordination-plugin.js +5 -0
- package/src/utils/fs.d.ts +1 -0
- package/src/utils/fs.js +4 -0
- package/src/utils/has-webpack-plugin.d.ts +2 -0
- package/src/utils/has-webpack-plugin.js +11 -0
- package/src/utils/normalize.d.ts +1 -0
- package/src/utils/normalize.js +4 -0
- package/src/utils/versions.d.ts +4 -0
- package/src/utils/versions.js +7 -0
- package/src/utils/wait-for-port-open.d.ts +5 -0
- package/src/utils/wait-for-port-open.js +45 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
7
|
+
const versions_1 = require("@nx/js/src/utils/versions");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const versions_2 = require("../../utils/versions");
|
|
10
|
+
const init_1 = require("../init/init");
|
|
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
|
+
function createApplicationFiles(tree, options) {
|
|
16
|
+
if (options.bundler === 'vite') {
|
|
17
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-vite'), options.appProjectRoot, {
|
|
18
|
+
...options,
|
|
19
|
+
...(0, devkit_1.names)(options.name),
|
|
20
|
+
tmpl: '',
|
|
21
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
22
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
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
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function setupBundler(tree, options) {
|
|
54
|
+
const main = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/main.ts');
|
|
55
|
+
const tsConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json');
|
|
56
|
+
const assets = [
|
|
57
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/favicon.ico'),
|
|
58
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/assets'),
|
|
59
|
+
];
|
|
60
|
+
if (options.bundler === 'webpack') {
|
|
61
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_2.nxVersion);
|
|
62
|
+
await configurationGenerator(tree, {
|
|
63
|
+
target: 'web',
|
|
64
|
+
project: options.projectName,
|
|
65
|
+
main,
|
|
66
|
+
tsConfig,
|
|
67
|
+
compiler: options.compiler ?? 'babel',
|
|
68
|
+
devServer: true,
|
|
69
|
+
webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
|
|
70
|
+
skipFormat: true,
|
|
71
|
+
addPlugin: options.addPlugin,
|
|
72
|
+
});
|
|
73
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
74
|
+
if (project.targets.build) {
|
|
75
|
+
const prodConfig = project.targets.build.configurations.production;
|
|
76
|
+
const buildOptions = project.targets.build.options;
|
|
77
|
+
buildOptions.assets = assets;
|
|
78
|
+
buildOptions.index = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html');
|
|
79
|
+
buildOptions.baseHref = '/';
|
|
80
|
+
buildOptions.styles = [
|
|
81
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
|
|
82
|
+
];
|
|
83
|
+
// We can delete that, because this projest is an application
|
|
84
|
+
// and applications have a .babelrc file in their root dir.
|
|
85
|
+
// So Nx will find it and use it
|
|
86
|
+
delete buildOptions.babelUpwardRootMode;
|
|
87
|
+
buildOptions.scripts = [];
|
|
88
|
+
prodConfig.fileReplacements = [
|
|
89
|
+
{
|
|
90
|
+
replace: (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/environments/environment.ts`),
|
|
91
|
+
with: (0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/environments/environment.prod.ts`),
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
prodConfig.optimization = true;
|
|
95
|
+
prodConfig.outputHashing = 'all';
|
|
96
|
+
prodConfig.sourceMap = false;
|
|
97
|
+
prodConfig.namedChunks = false;
|
|
98
|
+
prodConfig.extractLicenses = true;
|
|
99
|
+
prodConfig.vendorChunk = false;
|
|
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).
|
|
103
|
+
}
|
|
104
|
+
else if (options.bundler === 'none') {
|
|
105
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
106
|
+
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, `@nx/js:${options.compiler}`);
|
|
107
|
+
project.targets.build = {
|
|
108
|
+
executor: `@nx/js:${options.compiler}`,
|
|
109
|
+
outputs: ['{options.outputPath}'],
|
|
110
|
+
options: {
|
|
111
|
+
main,
|
|
112
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.appProjectRoot),
|
|
113
|
+
tsConfig,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error('Unsupported bundler type');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function addProject(tree, options) {
|
|
123
|
+
const targets = {};
|
|
124
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
|
|
125
|
+
projectType: 'application',
|
|
126
|
+
root: options.appProjectRoot,
|
|
127
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src'),
|
|
128
|
+
tags: options.parsedTags,
|
|
129
|
+
targets,
|
|
130
|
+
}, options.standaloneConfig);
|
|
131
|
+
}
|
|
132
|
+
function setDefaults(tree, options) {
|
|
133
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
134
|
+
nxJson.generators = nxJson.generators || {};
|
|
135
|
+
nxJson.generators['@nx/web:application'] = {
|
|
136
|
+
style: options.style,
|
|
137
|
+
linter: options.linter,
|
|
138
|
+
unitTestRunner: options.unitTestRunner,
|
|
139
|
+
e2eTestRunner: options.e2eTestRunner,
|
|
140
|
+
...nxJson.generators['@nx/web:application'],
|
|
141
|
+
};
|
|
142
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
143
|
+
}
|
|
144
|
+
async function applicationGenerator(host, schema) {
|
|
145
|
+
return await applicationGeneratorInternal(host, {
|
|
146
|
+
addPlugin: false,
|
|
147
|
+
projectNameAndRootFormat: 'derived',
|
|
148
|
+
...schema,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
exports.applicationGenerator = applicationGenerator;
|
|
152
|
+
async function applicationGeneratorInternal(host, schema) {
|
|
153
|
+
const options = await normalizeOptions(host, schema);
|
|
154
|
+
const tasks = [];
|
|
155
|
+
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
156
|
+
js: false,
|
|
157
|
+
skipFormat: true,
|
|
158
|
+
});
|
|
159
|
+
tasks.push(jsInitTask);
|
|
160
|
+
const webTask = await (0, init_1.webInitGenerator)(host, {
|
|
161
|
+
...options,
|
|
162
|
+
skipFormat: true,
|
|
163
|
+
});
|
|
164
|
+
tasks.push(webTask);
|
|
165
|
+
await addProject(host, options);
|
|
166
|
+
if (options.bundler !== 'vite') {
|
|
167
|
+
await setupBundler(host, options);
|
|
168
|
+
}
|
|
169
|
+
createApplicationFiles(host, options);
|
|
170
|
+
if (options.bundler === 'vite') {
|
|
171
|
+
const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_2.nxVersion);
|
|
172
|
+
// We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
|
|
173
|
+
// See: https://vitejs.dev/guide/env-and-mode.html
|
|
174
|
+
if (host.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'))) {
|
|
175
|
+
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'));
|
|
176
|
+
}
|
|
177
|
+
const viteTask = await viteConfigurationGenerator(host, {
|
|
178
|
+
uiFramework: 'none',
|
|
179
|
+
project: options.projectName,
|
|
180
|
+
newProject: true,
|
|
181
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
182
|
+
inSourceTests: options.inSourceTests,
|
|
183
|
+
skipFormat: true,
|
|
184
|
+
addPlugin: options.addPlugin,
|
|
185
|
+
});
|
|
186
|
+
tasks.push(viteTask);
|
|
187
|
+
createOrEditViteConfig(host, {
|
|
188
|
+
project: options.projectName,
|
|
189
|
+
includeLib: false,
|
|
190
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
191
|
+
inSourceTests: options.inSourceTests,
|
|
192
|
+
}, false);
|
|
193
|
+
}
|
|
194
|
+
if (options.bundler !== 'vite' && options.unitTestRunner === 'vitest') {
|
|
195
|
+
const { vitestGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_2.nxVersion);
|
|
196
|
+
const vitestTask = await vitestGenerator(host, {
|
|
197
|
+
uiFramework: 'none',
|
|
198
|
+
project: options.projectName,
|
|
199
|
+
coverageProvider: 'v8',
|
|
200
|
+
inSourceTests: options.inSourceTests,
|
|
201
|
+
skipFormat: true,
|
|
202
|
+
addPlugin: options.addPlugin,
|
|
203
|
+
});
|
|
204
|
+
tasks.push(vitestTask);
|
|
205
|
+
createOrEditViteConfig(host, {
|
|
206
|
+
project: options.projectName,
|
|
207
|
+
includeLib: false,
|
|
208
|
+
includeVitest: true,
|
|
209
|
+
inSourceTests: options.inSourceTests,
|
|
210
|
+
}, true);
|
|
211
|
+
}
|
|
212
|
+
if ((options.bundler === 'vite' || options.unitTestRunner === 'vitest') &&
|
|
213
|
+
options.inSourceTests) {
|
|
214
|
+
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/app/app.element.spec.ts`));
|
|
215
|
+
}
|
|
216
|
+
if (options.linter === 'eslint') {
|
|
217
|
+
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_2.nxVersion);
|
|
218
|
+
const lintTask = await lintProjectGenerator(host, {
|
|
219
|
+
linter: options.linter,
|
|
220
|
+
project: options.projectName,
|
|
221
|
+
tsConfigPaths: [
|
|
222
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
223
|
+
],
|
|
224
|
+
unitTestRunner: options.unitTestRunner,
|
|
225
|
+
skipFormat: true,
|
|
226
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
227
|
+
addPlugin: options.addPlugin,
|
|
228
|
+
});
|
|
229
|
+
tasks.push(lintTask);
|
|
230
|
+
}
|
|
231
|
+
if (options.e2eTestRunner === 'cypress') {
|
|
232
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
|
|
233
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
234
|
+
root: options.e2eProjectRoot,
|
|
235
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
236
|
+
projectType: 'application',
|
|
237
|
+
targets: {},
|
|
238
|
+
tags: [],
|
|
239
|
+
implicitDependencies: [options.projectName],
|
|
240
|
+
});
|
|
241
|
+
const cypressTask = await configurationGenerator(host, {
|
|
242
|
+
...options,
|
|
243
|
+
project: options.e2eProjectName,
|
|
244
|
+
devServerTarget: `${options.projectName}:serve`,
|
|
245
|
+
baseUrl: 'http://localhost:4200',
|
|
246
|
+
directory: 'src',
|
|
247
|
+
skipFormat: true,
|
|
248
|
+
});
|
|
249
|
+
tasks.push(cypressTask);
|
|
250
|
+
}
|
|
251
|
+
else if (options.e2eTestRunner === 'playwright') {
|
|
252
|
+
const { configurationGenerator: playwrightConfigGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_2.nxVersion);
|
|
253
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
254
|
+
root: options.e2eProjectRoot,
|
|
255
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
256
|
+
projectType: 'application',
|
|
257
|
+
targets: {},
|
|
258
|
+
implicitDependencies: [options.projectName],
|
|
259
|
+
});
|
|
260
|
+
const playwrightTask = await playwrightConfigGenerator(host, {
|
|
261
|
+
project: options.e2eProjectName,
|
|
262
|
+
skipFormat: true,
|
|
263
|
+
skipPackageJson: false,
|
|
264
|
+
directory: 'src',
|
|
265
|
+
js: false,
|
|
266
|
+
linter: options.linter,
|
|
267
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
268
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
|
|
269
|
+
webServerAddress: 'http://localhost:4200',
|
|
270
|
+
addPlugin: options.addPlugin,
|
|
271
|
+
});
|
|
272
|
+
tasks.push(playwrightTask);
|
|
273
|
+
}
|
|
274
|
+
if (options.unitTestRunner === 'jest') {
|
|
275
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_2.nxVersion);
|
|
276
|
+
const jestTask = await configurationGenerator(host, {
|
|
277
|
+
project: options.projectName,
|
|
278
|
+
skipSerializers: true,
|
|
279
|
+
setupFile: 'web-components',
|
|
280
|
+
compiler: options.compiler,
|
|
281
|
+
skipFormat: true,
|
|
282
|
+
addPlugin: options.addPlugin,
|
|
283
|
+
});
|
|
284
|
+
tasks.push(jestTask);
|
|
285
|
+
}
|
|
286
|
+
if (options.compiler === 'swc') {
|
|
287
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.swcrc'), {
|
|
288
|
+
jsc: {
|
|
289
|
+
parser: {
|
|
290
|
+
syntax: 'typescript',
|
|
291
|
+
},
|
|
292
|
+
target: 'es2016',
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@swc/core': versions_1.swcCoreVersion, 'swc-loader': versions_2.swcLoaderVersion });
|
|
296
|
+
tasks.push(installTask);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.babelrc'), {
|
|
300
|
+
presets: ['@nx/js/babel'],
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
setDefaults(host, options);
|
|
304
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, { '@types/node': versions_2.typesNodeVersion }));
|
|
305
|
+
if (!schema.skipFormat) {
|
|
306
|
+
await (0, devkit_1.formatFiles)(host);
|
|
307
|
+
}
|
|
308
|
+
tasks.push(() => {
|
|
309
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
|
|
310
|
+
});
|
|
311
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
312
|
+
}
|
|
313
|
+
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
314
|
+
async function normalizeOptions(host, options) {
|
|
315
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
316
|
+
name: options.name,
|
|
317
|
+
projectType: 'application',
|
|
318
|
+
directory: options.directory,
|
|
319
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
320
|
+
callingGenerator: '@nx/web:application',
|
|
321
|
+
});
|
|
322
|
+
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
|
+
const e2eProjectName = `${appProjectName}-e2e`;
|
|
328
|
+
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
329
|
+
const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
|
|
330
|
+
const parsedTags = options.tags
|
|
331
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
332
|
+
: [];
|
|
333
|
+
if (options.bundler === 'vite' && options.unitTestRunner !== 'none') {
|
|
334
|
+
options.unitTestRunner = 'vitest';
|
|
335
|
+
}
|
|
336
|
+
options.style = options.style || 'css';
|
|
337
|
+
options.linter = options.linter || 'eslint';
|
|
338
|
+
options.unitTestRunner = options.unitTestRunner || 'jest';
|
|
339
|
+
options.e2eTestRunner = options.e2eTestRunner || 'cypress';
|
|
340
|
+
return {
|
|
341
|
+
...options,
|
|
342
|
+
prefix: options.prefix ?? npmScope ?? 'app',
|
|
343
|
+
name: (0, devkit_1.names)(options.name).fileName,
|
|
344
|
+
compiler: options.compiler ?? 'babel',
|
|
345
|
+
bundler: options.bundler ?? 'webpack',
|
|
346
|
+
projectName: appProjectName,
|
|
347
|
+
appProjectRoot,
|
|
348
|
+
e2eProjectRoot,
|
|
349
|
+
e2eProjectName,
|
|
350
|
+
parsedTags,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
exports.default = applicationGenerator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title><%= className %></title>
|
|
6
|
+
<base href="/" />
|
|
7
|
+
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
10
|
+
<link rel="stylesheet" href="/src/styles.<%= style %>" />
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<<%= prefix %>-root></<%= prefix %>-root>
|
|
14
|
+
<script type="module" src="/src/main.ts"></script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
Binary file
|