@nx/nuxt 18.1.0-beta.1 → 18.1.0-beta.3

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/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './src/utils/versions';
2
2
  export { applicationGenerator } from './src/generators/application/application';
3
3
  export { type InitSchema } from './src/generators/init/schema';
4
4
  export { nuxtInitGenerator } from './src/generators/init/init';
5
+ export { storybookConfigurationGenerator } from './src/generators/storybook-configuration/configuration';
package/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nuxtInitGenerator = exports.applicationGenerator = void 0;
3
+ exports.storybookConfigurationGenerator = exports.nuxtInitGenerator = exports.applicationGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("./src/utils/versions"), exports);
6
6
  var application_1 = require("./src/generators/application/application");
7
7
  Object.defineProperty(exports, "applicationGenerator", { enumerable: true, get: function () { return application_1.applicationGenerator; } });
8
8
  var init_1 = require("./src/generators/init/init");
9
9
  Object.defineProperty(exports, "nuxtInitGenerator", { enumerable: true, get: function () { return init_1.nuxtInitGenerator; } });
10
+ var configuration_1 = require("./src/generators/storybook-configuration/configuration");
11
+ Object.defineProperty(exports, "storybookConfigurationGenerator", { enumerable: true, get: function () { return configuration_1.storybookConfigurationGenerator; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nuxt",
3
- "version": "18.1.0-beta.1",
3
+ "version": "18.1.0-beta.3",
4
4
  "private": false,
5
5
  "description": "The Nuxt plugin for Nx contains executors and generators for managing Nuxt applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Vitest, Cypress, and Storybook.\n\n- Generators for applications, libraries, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -30,10 +30,11 @@
30
30
  "dependencies": {
31
31
  "tslib": "^2.3.0",
32
32
  "@nuxt/kit": "^3.10.0",
33
- "@nx/devkit": "18.1.0-beta.1",
34
- "@nx/js": "18.1.0-beta.1",
35
- "@nx/eslint": "18.1.0-beta.1",
36
- "@nx/vue": "18.1.0-beta.1"
33
+ "@nx/devkit": "18.1.0-beta.3",
34
+ "@nx/js": "18.1.0-beta.3",
35
+ "@nx/eslint": "18.1.0-beta.3",
36
+ "@nx/vue": "18.1.0-beta.3",
37
+ "@nx/vite": "18.1.0-beta.3"
37
38
  },
38
39
  "peerDependencies": {},
39
40
  "publishConfig": {
@@ -44,8 +44,6 @@ async function applicationGenerator(tree, schema) {
44
44
  tmpl: '',
45
45
  style: options.style,
46
46
  projectRoot: options.appProjectRoot,
47
- buildDirectory: (0, devkit_1.joinPathFragments)(`dist/${options.appProjectRoot}/.nuxt`),
48
- nitroOutputDir: (0, devkit_1.joinPathFragments)(`dist/${options.appProjectRoot}/.output`),
49
47
  hasVitest: options.unitTestRunner === 'vitest',
50
48
  });
51
49
  if (options.style === 'none') {
@@ -5,7 +5,6 @@ import { defineNuxtConfig } from 'nuxt/config';
5
5
  export default defineNuxtConfig({
6
6
  workspaceDir: '<%= offsetFromRoot %>',
7
7
  srcDir: 'src',
8
- buildDir: '<%= offsetFromRoot %><%= buildDirectory %>',
9
8
  devtools: { enabled: true },
10
9
  devServer: {
11
10
  host: 'localhost',
@@ -18,7 +17,7 @@ export default defineNuxtConfig({
18
17
  },
19
18
  },
20
19
  imports: {
21
- autoImport: false,
20
+ autoImport: true,
22
21
  },
23
22
  <% if (style !== 'none') { %>
24
23
  css: ['~/assets/css/styles.<%= style %>'],
@@ -28,9 +27,4 @@ export default defineNuxtConfig({
28
27
  nxViteTsPaths()
29
28
  ],
30
29
  },
31
- nitro: {
32
- output: {
33
- dir: '<%= offsetFromRoot %><%= nitroOutputDir %>',
34
- },
35
- },
36
30
  });
@@ -21,6 +21,10 @@ async function addE2e(host, options) {
21
21
  bundler: 'vite',
22
22
  skipFormat: true,
23
23
  devServerTarget: `${options.projectName}:serve`,
24
+ webServerCommands: {
25
+ default: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.projectName}`,
26
+ },
27
+ ciWebServerCommand: `nx run ${options.projectName}:serve-static`,
24
28
  baseUrl: 'http://localhost:4200',
25
29
  jsx: true,
26
30
  addPlugin: true,
@@ -7,6 +7,7 @@ function updateDependencies(host, schema) {
7
7
  return (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
8
8
  '@nx/nuxt': versions_1.nxVersion,
9
9
  nuxt: versions_1.nuxtVersion,
10
+ '@nx/vite': versions_1.nxVersion,
10
11
  }, undefined, schema.keepExistingVersions);
11
12
  }
12
13
  exports.updateDependencies = updateDependencies;
@@ -43,6 +44,7 @@ function addPlugin(tree) {
43
44
  options: {
44
45
  buildTargetName: 'build',
45
46
  serveTargetName: 'serve',
47
+ serveStaticTargetName: 'serve-static',
46
48
  },
47
49
  });
48
50
  }
@@ -1,4 +1,4 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
- export declare function storybookConfigurationGenerator(host: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
3
+ export declare function storybookConfigurationGenerator(tree: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
4
4
  export default storybookConfigurationGenerator;
@@ -7,22 +7,21 @@ const vue_1 = require("@nx/vue");
7
7
  * This generator is basically the Vue one, but for Nuxt we
8
8
  * are just adding the styles in `.storybook/preview.ts`
9
9
  */
10
- async function storybookConfigurationGenerator(host, options) {
11
- const storybookConfigurationGenerator = await (0, vue_1.storybookConfigurationGenerator)(host, {
10
+ async function storybookConfigurationGenerator(tree, options) {
11
+ const storybookConfigurationGenerator = await (0, vue_1.storybookConfigurationGenerator)(tree, {
12
12
  ...options,
13
13
  addPlugin: true,
14
14
  });
15
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.project);
16
- const storybookConfigFolder = projectConfiguration.targets?.storybook?.options?.configDir;
17
- host.write(`${storybookConfigFolder}/preview.${options.tsConfiguration ? 'ts' : 'js'}`, `import '../src/assets/css/styles.css';`);
18
- (0, devkit_1.updateJson)(host, `${projectConfiguration.root}/tsconfig.storybook.json`, (json) => {
15
+ const { root } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
16
+ tree.write((0, devkit_1.joinPathFragments)(root, '.storybook', 'preview.' + options.tsConfiguration ? 'ts' : 'js'), `import '../src/assets/css/styles.css';`);
17
+ (0, devkit_1.updateJson)(tree, `${root}/tsconfig.storybook.json`, (json) => {
19
18
  json.compilerOptions = {
20
19
  ...json.compilerOptions,
21
20
  composite: true,
22
21
  };
23
22
  return json;
24
23
  });
25
- await (0, devkit_1.formatFiles)(host);
24
+ await (0, devkit_1.formatFiles)(tree);
26
25
  return (0, devkit_1.runTasksInSerial)(storybookConfigurationGenerator);
27
26
  }
28
27
  exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const executor_utils_1 = require("../../utils/executor-utils");
5
+ const path_1 = require("path");
6
+ async function default_1(tree) {
7
+ const projects = (0, devkit_1.getProjects)(tree);
8
+ for (const project of projects.values()) {
9
+ const nuxtConfigPath = findNuxtConfig(tree, project.root);
10
+ if (!nuxtConfigPath) {
11
+ continue;
12
+ }
13
+ const nuxtConfig = await getInfoFromNuxtConfig(nuxtConfigPath, project.root);
14
+ const buildDir = nuxtConfig.buildDir ?? '.nuxt';
15
+ const tsConfigPath = (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.json');
16
+ if (tree.exists(tsConfigPath)) {
17
+ (0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
18
+ if (!json.include) {
19
+ json.include = [];
20
+ }
21
+ if (!json.include.includes(buildDir + '/nuxt.d.ts')) {
22
+ json.include.push(buildDir + '/nuxt.d.ts');
23
+ }
24
+ return json;
25
+ });
26
+ }
27
+ }
28
+ await (0, devkit_1.formatFiles)(tree);
29
+ }
30
+ exports.default = default_1;
31
+ function findNuxtConfig(tree, projectRoot) {
32
+ const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];
33
+ for (const ext of allowsExt) {
34
+ if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, `nuxt.config.${ext}`))) {
35
+ return (0, devkit_1.joinPathFragments)(projectRoot, `nuxt.config.${ext}`);
36
+ }
37
+ }
38
+ }
39
+ async function getInfoFromNuxtConfig(configFilePath, projectRoot) {
40
+ const { loadNuxtConfig } = await (0, executor_utils_1.loadNuxtKitDynamicImport)();
41
+ const config = await loadNuxtConfig({
42
+ cwd: (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot),
43
+ configFile: (0, path_1.basename)(configFilePath),
44
+ });
45
+ return {
46
+ buildDir: config?.buildDir,
47
+ };
48
+ }
@@ -3,5 +3,7 @@ export declare const createDependencies: CreateDependencies;
3
3
  export interface NuxtPluginOptions {
4
4
  buildTargetName?: string;
5
5
  serveTargetName?: string;
6
+ serveStaticTargetName?: string;
7
+ buildStaticTargetName?: string;
6
8
  }
7
9
  export declare const createNodes: CreateNodes<NuxtPluginOptions>;
@@ -58,6 +58,8 @@ async function buildNuxtTargets(configFilePath, projectRoot, options, context) {
58
58
  const targets = {};
59
59
  targets[options.buildTargetName] = buildTarget(options.buildTargetName, namedInputs, buildOutputs, projectRoot);
60
60
  targets[options.serveTargetName] = serveTarget(projectRoot);
61
+ targets[options.serveStaticTargetName] = serveStaticTarget(options);
62
+ targets[options.buildStaticTargetName] = buildStaticTarget(options.buildStaticTargetName, namedInputs, buildOutputs, projectRoot);
61
63
  return targets;
62
64
  }
63
65
  function buildTarget(buildTargetName, namedInputs, buildOutputs, projectRoot) {
@@ -86,6 +88,35 @@ function serveTarget(projectRoot) {
86
88
  };
87
89
  return targetConfig;
88
90
  }
91
+ function serveStaticTarget(options) {
92
+ const targetConfig = {
93
+ executor: '@nx/web:file-server',
94
+ options: {
95
+ buildTarget: `${options.buildStaticTargetName}`,
96
+ staticFilePath: '{projectRoot}/dist',
97
+ port: 4200,
98
+ },
99
+ };
100
+ return targetConfig;
101
+ }
102
+ function buildStaticTarget(buildStaticTargetName, namedInputs, buildOutputs, projectRoot) {
103
+ const targetConfig = {
104
+ command: `nuxt build --prerender`,
105
+ options: { cwd: projectRoot },
106
+ cache: true,
107
+ dependsOn: [`^${buildStaticTargetName}`],
108
+ inputs: [
109
+ ...('production' in namedInputs
110
+ ? ['production', '^production']
111
+ : ['default', '^default']),
112
+ {
113
+ externalDependencies: ['nuxt'],
114
+ },
115
+ ],
116
+ outputs: buildOutputs,
117
+ };
118
+ return targetConfig;
119
+ }
89
120
  async function getInfoFromNuxtConfig(configFilePath, context, projectRoot) {
90
121
  const { loadNuxtConfig } = await (0, executor_utils_1.loadNuxtKitDynamicImport)();
91
122
  const config = await loadNuxtConfig({
@@ -99,12 +130,11 @@ async function getInfoFromNuxtConfig(configFilePath, context, projectRoot) {
99
130
  function getOutputs(nuxtConfig, projectRoot) {
100
131
  let nuxtBuildDir = nuxtConfig?.buildDir;
101
132
  if (nuxtConfig?.buildDir && (0, path_1.basename)(nuxtConfig?.buildDir) === '.nuxt') {
102
- // buildDir will most probably be `../dist/my-app/.nuxt`
103
- // we want the "general" outputPath to be `../dist/my-app`
133
+ // if buildDir exists, it will be `something/something/.nuxt`
134
+ // we want the "general" outputPath to be `something/something`
104
135
  nuxtBuildDir = nuxtConfig.buildDir.replace((0, path_1.basename)(nuxtConfig.buildDir), '');
105
136
  }
106
- const buildOutputPath = normalizeOutputPath(nuxtBuildDir, projectRoot) ??
107
- '{workspaceRoot}/dist/{projectRoot}';
137
+ const buildOutputPath = normalizeOutputPath(nuxtBuildDir, projectRoot);
108
138
  return {
109
139
  buildOutputs: [buildOutputPath],
110
140
  };
@@ -112,10 +142,10 @@ function getOutputs(nuxtConfig, projectRoot) {
112
142
  function normalizeOutputPath(outputPath, projectRoot) {
113
143
  if (!outputPath) {
114
144
  if (projectRoot === '.') {
115
- return `{projectRoot}/dist`;
145
+ return `{projectRoot}`;
116
146
  }
117
147
  else {
118
- return `{workspaceRoot}/dist/{projectRoot}`;
148
+ return `{workspaceRoot}/{projectRoot}`;
119
149
  }
120
150
  }
121
151
  else {
@@ -136,5 +166,7 @@ function normalizeOptions(options) {
136
166
  options ??= {};
137
167
  options.buildTargetName ??= 'build';
138
168
  options.serveTargetName ??= 'serve';
169
+ options.serveStaticTargetName ??= 'serve-static';
170
+ options.buildStaticTargetName ??= 'build-static';
139
171
  return options;
140
172
  }
@@ -4,8 +4,8 @@ exports.addLinting = void 0;
4
4
  const eslint_1 = require("@nx/eslint");
5
5
  const path_1 = require("nx/src/utils/path");
6
6
  const devkit_1 = require("@nx/devkit");
7
- const lint_1 = require("./lint");
8
7
  const vue_1 = require("@nx/vue");
8
+ const versions_1 = require("./versions");
9
9
  async function addLinting(host, options) {
10
10
  const tasks = [];
11
11
  if (options.linter === 'eslint') {
@@ -19,10 +19,22 @@ async function addLinting(host, options) {
19
19
  addPlugin: true,
20
20
  });
21
21
  tasks.push(lintTask);
22
- (0, devkit_1.updateJson)(host, (0, path_1.joinPathFragments)(options.projectRoot, '.eslintrc.json'), lint_1.extendNuxtEslintJson);
23
22
  (0, vue_1.editEslintConfigFiles)(host, options.projectRoot, options.rootProject);
24
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, {
25
- ...lint_1.extraEslintDependencies.devDependencies,
23
+ (0, devkit_1.updateJson)(host, (0, path_1.joinPathFragments)(options.projectRoot, '.eslintrc.json'), (json) => {
24
+ const { extends: pluginExtends, ignorePatterns: pluginIgnorePatters, ...config } = json;
25
+ return {
26
+ extends: ['@nuxt/eslint-config', ...(pluginExtends || [])],
27
+ ignorePatterns: [
28
+ ...(pluginIgnorePatters || []),
29
+ '.nuxt/**',
30
+ '.output/**',
31
+ 'node_modules',
32
+ ],
33
+ ...config,
34
+ };
35
+ });
36
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
37
+ '@nuxt/eslint-config': versions_1.nuxtEslintConfigVersion,
26
38
  });
27
39
  tasks.push(installTask);
28
40
  }
@@ -8,7 +8,7 @@ function createTsConfig(host, options, relativePathToRootTsConfig) {
8
8
  const json = {
9
9
  compilerOptions: {},
10
10
  files: [],
11
- include: [],
11
+ include: ['.nuxt/nuxt.d.ts'],
12
12
  references: [
13
13
  {
14
14
  path: './tsconfig.app.json',
@@ -1,7 +0,0 @@
1
- export declare const extraEslintDependencies: {
2
- dependencies: {};
3
- devDependencies: {
4
- '@nuxt/eslint-config': string;
5
- };
6
- };
7
- export declare const extendNuxtEslintJson: (json: any) => any;
package/src/utils/lint.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extendNuxtEslintJson = exports.extraEslintDependencies = void 0;
4
- const versions_1 = require("./versions");
5
- exports.extraEslintDependencies = {
6
- dependencies: {},
7
- devDependencies: {
8
- '@nuxt/eslint-config': versions_1.nuxtEslintConfigVersion,
9
- },
10
- };
11
- const extendNuxtEslintJson = (json) => {
12
- const { extends: pluginExtends, ...config } = json;
13
- return {
14
- extends: ['@nuxt/eslint-config', ...(pluginExtends || [])],
15
- ignorePatterns: ['.nuxt', 'node_modules', '.output'],
16
- ...config,
17
- };
18
- };
19
- exports.extendNuxtEslintJson = extendNuxtEslintJson;