@dword-design/base-config-nuxt 3.2.16 → 4.0.0

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/dist/analyze.js CHANGED
@@ -1,4 +1,2 @@
1
- import { execa } from 'execa';
2
- export default (() => execa('nuxt-babel', ['build', '--analyze', '--config-file', require.resolve("./nuxt.config")], {
3
- stdio: 'inherit'
4
- }));
1
+ import { execaCommand } from 'execa';
2
+ export default (() => execaCommand('nuxt build --analyze'));
@@ -1,20 +1,18 @@
1
- import babelConfig from '@dword-design/babel-config';
2
1
  import filter from "@dword-design/functions/dist/filter.js";
3
2
  import first from "@dword-design/functions/dist/first.js";
4
3
  import map from "@dword-design/functions/dist/map.js";
4
+ import jitiBabelTransform from '@dword-design/jiti-babel-transform';
5
5
  import jiti from 'jiti';
6
6
  import P from 'path';
7
7
  export default (path => {
8
- if (P.basename(path) === 'nuxt.config.js') {
8
+ if (P.basename(path) === 'config.js') {
9
9
  var _ref, _modules;
10
10
  const jitiInstance = jiti(process.cwd(), {
11
11
  esmResolve: true,
12
12
  interopDefault: true,
13
- transformOptions: {
14
- babel: babelConfig
15
- }
13
+ transform: jitiBabelTransform
16
14
  });
17
- const config = jitiInstance(`./nuxt.config.js`);
15
+ const config = jitiInstance('./config.js');
18
16
  const modules = [...(config.modules || []), ...(config.buildModules || [])];
19
17
  return _ref = (_modules = modules, map(mod => {
20
18
  var _concat;
package/dist/dev.js CHANGED
@@ -1,13 +1,19 @@
1
- import { Builder, Nuxt } from 'nuxt';
2
- import getNuxtConfig from "./get-nuxt-config.js";
3
- export default (async nuxtConfig => {
4
- const nuxt = new Nuxt({
5
- ...getNuxtConfig(),
6
- _build: true,
7
- dev: true,
8
- ...nuxtConfig
1
+ import { execa } from 'execa';
2
+ import { createRequire } from 'module';
3
+ const _require = createRequire(import.meta.url);
4
+ const nuxtWrapper = _require.resolve('./nuxt-wrapper.js');
5
+ export default ((options = {}) => {
6
+ options = {
7
+ log: process.env.NODE_ENV !== 'test',
8
+ telemetry: process.env.NODE_ENV !== 'test',
9
+ ...options
10
+ };
11
+ return execa(nuxtWrapper, ['dev'], {
12
+ [options.log ? 'stdio' : 'stderr']: 'inherit',
13
+ ...(options.telemetry ? {} : {
14
+ env: {
15
+ NUXT_TELEMETRY_DISABLED: 1
16
+ }
17
+ })
9
18
  });
10
- await new Builder(nuxt).build();
11
- await nuxt.listen();
12
- return nuxt;
13
19
  });
@@ -2,6 +2,9 @@ import packageName from 'depcheck-package-name';
2
2
  export default {
3
3
  extends: packageName`@dword-design/eslint-config`,
4
4
  rules: {
5
+ 'import/no-unresolved': ['error', {
6
+ ignore: ['#imports']
7
+ }],
5
8
  'import/no-webpack-loader-syntax': 'off'
6
9
  }
7
10
  };
package/dist/index.js CHANGED
@@ -1,18 +1,21 @@
1
1
  import depcheckParserSass from '@dword-design/depcheck-parser-sass';
2
+ import endent from "@dword-design/functions/dist/endent.js";
2
3
  import packageName from 'depcheck-package-name';
3
4
  import depcheckParserVue from 'depcheck-parser-vue';
4
- import fs from 'fs-extra';
5
+ import { globby } from 'globby';
6
+ import { createRequire } from 'module';
7
+ import outputFiles from 'output-files';
8
+ import P from 'path';
5
9
  import analyze from "./analyze.js";
6
10
  import depcheckSpecial from "./depcheck-special.js";
7
11
  import dev from "./dev.js";
8
12
  import eslintConfig from "./eslint.config.js";
9
- import getNuxtConfig from "./get-nuxt-config.js";
10
13
  import lint from "./lint.js";
11
14
  import prepublishOnly from "./prepublish-only.js";
12
15
  import start from "./start.js";
13
- export { getNuxtConfig };
16
+ const _require = createRequire(import.meta.url);
14
17
  export default {
15
- allowedMatches: ['.stylelintrc.json', 'api', 'assets', 'components', 'content', 'i18n', 'layouts', 'middleware', 'model', 'modules', 'nuxt.config.js', 'pages', 'plugins', 'static', 'store', 'types'],
18
+ allowedMatches: ['.stylelintrc.json', 'api', 'assets', 'components', 'content', 'i18n', 'layouts', 'middleware', 'model', 'modules', 'config.js', 'pages', 'plugins', 'static', 'store', 'types'],
16
19
  commands: {
17
20
  analyze,
18
21
  dev,
@@ -26,16 +29,78 @@ export default {
26
29
  },
27
30
  specials: [depcheckSpecial]
28
31
  },
29
- editorIgnore: ['.eslintcache', '.stylelintrc.json', '.nuxt', 'dist'],
32
+ editorIgnore: ['.eslintcache', '.stylelintrc.json', '.nuxt', 'app.vue', 'dist', 'nuxt.config.js'],
30
33
  eslintConfig,
31
- gitignore: ['/.eslintcache', '/.nuxt', '/dist'],
34
+ gitignore: ['/.eslintcache', '/.nuxt', '/app.vue', '/dist', '/nuxt.config.js'],
32
35
  lint,
36
+ nodeVersion: 18,
33
37
  npmPublish: true,
34
38
  packageConfig: {
35
39
  main: 'dist/index.js'
36
40
  },
37
- prepare: () => fs.outputFile('.stylelintrc.json', JSON.stringify({
38
- extends: packageName`@dword-design/stylelint-config`
39
- }, undefined, 2)),
41
+ prepare: async () => {
42
+ const projectModulePath = `./${P.relative(process.cwd(), _require.resolve('./modules/project/index.js')).split(P.sep).join('/')}`;
43
+ const translations = await globby('i18n/*.json');
44
+ const hasI18n = translations.length > 0;
45
+ await outputFiles({
46
+ '.stylelintrc.json': JSON.stringify({
47
+ extends: packageName`@dword-design/stylelint-config`
48
+ }, undefined, 2),
49
+ 'app.vue': endent`
50
+ <template>
51
+ <NuxtLayout>
52
+ <NuxtPage />
53
+ </NuxtLayout>
54
+ </template>
55
+
56
+ <script setup>
57
+ import { ${['useHead', ...(hasI18n ? ['useLocaleHead'] : []), 'useRuntimeConfig'].join(', ')} } from '#imports'
58
+
59
+ ${[hasI18n ? ['const i18nHead = useLocaleHead({ addSeoAttributes: true })'] : [], 'const runtimeConfig = useRuntimeConfig()'].join('\n')}
60
+
61
+ useHead({
62
+ ${[...(hasI18n ? [endent`
63
+ htmlAttrs: {
64
+ lang: i18nHead.value.htmlAttrs.lang,
65
+ },
66
+ link: i18nHead.value.link,
67
+ meta: i18nHead.value.meta,
68
+ `] : []), "titleTemplate: title => title ? `${title} | ${runtimeConfig.public.name}` : `${runtimeConfig.public.name}${runtimeConfig.public.title ? `: ${runtimeConfig.public.title}` : ''}`"].join('\n')}
69
+ })
70
+ </script>
71
+ `,
72
+ 'nuxt.config.js': endent`
73
+ import projectModule from '${projectModulePath}'
74
+ import jiti from 'jiti'
75
+ import dotenv from '@dword-design/dotenv-json-extended'
76
+ import jitiBabelTransform from '@dword-design/jiti-babel-transform'
77
+
78
+ dotenv.config()
79
+
80
+ let options
81
+ try {
82
+ const jitiInstance = jiti(process.cwd(), {
83
+ esmResolve: true,
84
+ interopDefault: true,
85
+ transform: jitiBabelTransform,
86
+ })
87
+ options = jitiInstance('./config.js')
88
+ } catch (error) {
89
+ if (error.message.startsWith("Cannot find module './config.js'\\n")) {
90
+ options = {}
91
+ } else {
92
+ throw error
93
+ }
94
+ }
95
+
96
+ export default {
97
+ modules: [
98
+ [projectModule, options],
99
+ ],
100
+ }
101
+ `
102
+ });
103
+ },
104
+ supportedNodeVersions: [16, 18],
40
105
  useJobMatrix: true
41
106
  };
@@ -1,29 +1,17 @@
1
- import babelConfig from '@dword-design/babel-config';
2
- import join from "@dword-design/functions/dist/join.js";
3
- import keys from "@dword-design/functions/dist/keys.js";
4
- import map from "@dword-design/functions/dist/map.js";
5
1
  import omit from "@dword-design/functions/dist/omit.js";
2
+ import { addPlugin, addTemplate, installModule } from '@nuxt/kit';
6
3
  import packageName from 'depcheck-package-name';
7
- import jiti from 'jiti';
8
4
  import { createRequire } from 'module';
9
- import nuxtPushPlugins from 'nuxt-push-plugins';
10
5
  import P from 'path';
11
- import sequential from 'promise-sequential';
12
- import axiosDynamicBaseurlModule from "./modules/axios-dynamic-baseurl/index.js";
13
- import babelModule from "./modules/babel.js";
14
- import bodyParserModule from "./modules/body-parser.js";
15
- import cssModulesModule from "./modules/css-modules.js";
16
- import dotenvModule from "./modules/dotenv.js";
6
+ import expressModule from "./modules/express/index.js";
17
7
  import i18nModule from "./modules/i18n/index.js";
18
8
  import localeLinkModule from "./modules/locale-link/index.js";
19
- import rawModule from "./modules/raw.js";
20
- import serverMiddlewareModule from "./modules/server-middleware/index.js";
9
+ import svgModule from "./modules/svg.js";
21
10
  const _require = createRequire(import.meta.url);
22
- export default async function () {
23
- var _ref, _projectConfig$router, _projectConfig, _defaultConfig$this$o, _ref2;
11
+ export default (async (options, nuxt) => {
24
12
  const defaultConfig = {
25
13
  bodyAttrs: {},
26
- css: [_require.resolve('./style.css')],
14
+ css: [],
27
15
  head: {},
28
16
  headAttrs: {},
29
17
  htmlAttrs: {},
@@ -31,96 +19,83 @@ export default async function () {
31
19
  name: 'Vue app',
32
20
  plugins: [],
33
21
  router: {},
34
- serverMiddleware: [],
35
22
  userScalable: true
36
23
  };
37
- let localConfig;
38
- try {
39
- const jitiInstance = jiti(this.options.rootDir, {
40
- esmResolve: true,
41
- interopDefault: true,
42
- transformOptions: {
43
- babel: babelConfig
44
- }
45
- });
46
- localConfig = jitiInstance('./nuxt.config.js');
47
- } catch (error) {
48
- if (error.message.startsWith("Cannot find module './nuxt.config.js'\n")) {
49
- localConfig = {};
50
- } else {
51
- throw error;
52
- }
53
- }
54
24
  const projectConfig = {
55
25
  ...defaultConfig,
56
- ...localConfig,
57
- css: [...defaultConfig.css, ...(localConfig.css || [])]
26
+ ...options,
27
+ css: [...defaultConfig.css, ...(options.css || [])]
58
28
  };
59
- this.options.watch.push(P.join(this.options.rootDir, 'nuxt.config.js'));
60
- this.options.publicRuntimeConfig.name = projectConfig.name;
61
- this.options.publicRuntimeConfig.title = projectConfig.title;
62
- /* istanbul ignore next */
63
- this.options.head.titleTemplate = function (title) {
64
- return title ? `${title} | ${this.$config.name}` : [this.$config.name, ...(this.$config.title ? [this.$config.title] : [])].join(': ');
65
- };
66
- this.options.head.link.push(...(projectConfig.head.link || []));
67
- this.options.head.meta.push({
68
- charset: 'utf-8'
69
- }, {
70
- content: (_ref = ['width=device-width', 'initial-scale=1', ...(projectConfig.userScalable ? [] : ['user-scalable=0'])], join(', ')(_ref)),
71
- name: 'viewport'
72
- }, {
29
+ nuxt.options.watch.push('config.js');
30
+ nuxt.options.runtimeConfig.public.name = projectConfig.name;
31
+ nuxt.options.runtimeConfig.public.title = projectConfig.title;
32
+ if (process.env.BASIC_AUTH_USER && process.env.BASIC_AUTH_PASSWORD) {
33
+ nuxt.options.runtimeConfig.basicAuth = {
34
+ pairs: {
35
+ [process.env.BASIC_AUTH_USER]: process.env.BASIC_AUTH_PASSWORD
36
+ }
37
+ };
38
+ }
39
+ nuxt.options.app.head.link.push(...(projectConfig.head.link || []));
40
+ nuxt.options.app.head.meta.push({
73
41
  content: projectConfig.name,
74
42
  hid: 'description',
75
43
  name: 'description'
76
44
  });
45
+ if (!projectConfig.userScalable) {
46
+ const viewportMeta = nuxt.options.app.head.meta.find(meta => meta.name === 'viewport');
47
+ viewportMeta.content += ', user-scalable=0';
48
+ }
77
49
  if (projectConfig.ogImage) {
78
- this.options.head.meta.push({
50
+ nuxt.options.app.head.meta.push({
79
51
  content: projectConfig.ogImage,
80
52
  hid: 'og:image',
81
53
  name: 'og:image'
82
54
  });
83
55
  }
84
56
  if (projectConfig.webApp) {
85
- this.options.head.meta.push({
57
+ nuxt.options.app.head.meta.push({
86
58
  content: 'yes',
87
59
  name: 'apple-mobile-web-app-capable'
88
60
  });
89
61
  }
90
- this.options.head.htmlAttrs = projectConfig.htmlAttrs;
91
- this.options.head.headAttrs = projectConfig.headAttrs;
92
- this.options.head.bodyAttrs = projectConfig.bodyAttrs;
93
- this.options.css.push(...projectConfig.css);
94
- this.options.serverMiddleware.push(...projectConfig.serverMiddleware);
95
- this.options.components = true;
96
- Object.assign(this.options.router, {
62
+ nuxt.options.app.head.htmlAttrs = projectConfig.htmlAttrs;
63
+ nuxt.options.app.head.bodyAttrs = projectConfig.bodyAttrs;
64
+ nuxt.options.css.push(...projectConfig.css);
65
+ Object.assign(nuxt.options.router.options, {
97
66
  linkActiveClass: 'active',
98
67
  routeNameSplitter: '.',
99
- ...(_projectConfig$router = projectConfig.router, omit('middleware')(_projectConfig$router))
68
+ ...projectConfig.router
100
69
  });
101
- this.options.router.middleware = [...this.options.router.middleware, ...(projectConfig.router.middleware || [])];
102
- Object.assign(this.options, (_projectConfig = projectConfig, omit((_defaultConfig$this$o = {
70
+ Object.assign(nuxt.options, omit(Object.keys({
103
71
  ...defaultConfig,
104
- ...this.options
105
- }, keys(_defaultConfig$this$o)))(_projectConfig)));
106
- await sequential((_ref2 = [[packageName`nuxt-basic-auth-module`, {
107
- enabled: process.env.BASIC_AUTH_USER && process.env.BASIC_AUTH_PASSWORD,
108
- name: process.env.BASIC_AUTH_USER,
109
- pass: process.env.BASIC_AUTH_PASSWORD
110
- }], babelModule, dotenvModule, [packageName`@nuxtjs/eslint-module`, {
72
+ ...nuxt.options
73
+ }))(projectConfig));
74
+ const modules = [[packageName`nuxt-basic-authentication-module`, {
75
+ enabled: nuxt.options.runtimeConfig.basicAuth !== undefined
76
+ }], [packageName`@nuxtjs/eslint-module`, {
77
+ cache: false,
111
78
  failOnWarning: true,
112
- fix: true
79
+ fix: true,
80
+ lintOnStart: false
113
81
  }], [packageName`@nuxtjs/stylelint-module`, {
114
82
  allowEmptyInput: true,
115
83
  failOnWarning: true,
116
- fix: true
117
- }], cssModulesModule, rawModule, i18nModule, bodyParserModule, [serverMiddlewareModule, {
118
- getExpress: projectConfig.getExpress
119
- }], packageName`@nuxtjs/axios`, axiosDynamicBaseurlModule, packageName`nuxt-svg-loader`, localeLinkModule, ...projectConfig.modules], map(module => () => this.addModule(module))(_ref2)));
120
- this.addTemplate({
84
+ fix: true,
85
+ lintOnStart: false
86
+ }], i18nModule, expressModule, svgModule, localeLinkModule, ...(projectConfig.modules || [])];
87
+ for (let module of modules) {
88
+ module = [].concat(module);
89
+ await installModule(module[0], module[1]);
90
+ }
91
+ addTemplate({
121
92
  fileName: P.join('project', 'project-config.js'),
122
93
  options: projectConfig,
123
94
  src: _require.resolve('./project-config.js.template')
124
95
  });
125
- nuxtPushPlugins(this, ...projectConfig.plugins);
126
- }
96
+ for (const plugin of projectConfig.plugins) {
97
+ addPlugin(plugin, {
98
+ append: true
99
+ });
100
+ }
101
+ });
@@ -0,0 +1,29 @@
1
+ import jitiBabelTransform from '@dword-design/jiti-babel-transform';
2
+ import express from 'express';
3
+ import mountFiles from 'express-mount-files';
4
+ import { fromNodeMiddleware } from 'h3';
5
+ import jiti from 'jiti';
6
+ import P from 'path';
7
+ import options from '#express/options.js';
8
+ const jitiOptions = {
9
+ esmResolve: true,
10
+ interopDefault: true,
11
+ transform: jitiBabelTransform
12
+ };
13
+ const jitiInstance = jiti(options.srcDir, jitiOptions);
14
+ let app = express().use(express.json()).use(express.urlencoded({
15
+ extended: false
16
+ }));
17
+ try {
18
+ const setupExpress = jitiInstance('./setup-express');
19
+ app = setupExpress(app);
20
+ } catch (error) {
21
+ if (!error.message.startsWith("Cannot find module './setup-express'")) {
22
+ throw error;
23
+ }
24
+ }
25
+ app.use('/api', mountFiles(P.resolve(options.srcDir, 'api'), {
26
+ jitiOptions,
27
+ paramChar: '_'
28
+ }));
29
+ export default fromNodeMiddleware(app);
@@ -0,0 +1,18 @@
1
+ import { addServerHandler, addTemplate, createResolver } from '@nuxt/kit';
2
+ import nuxtAliasPath from 'nuxt-alias-path';
3
+ import P from 'path';
4
+ const resolver = createResolver(import.meta.url);
5
+ const moduleName = 'express';
6
+ export default ((options, nuxt) => {
7
+ addTemplate({
8
+ filename: P.join(moduleName, 'options.js'),
9
+ getContents: () => `export default ${JSON.stringify({
10
+ srcDir: nuxt.options.srcDir
11
+ }, undefined, 2)}`,
12
+ write: true
13
+ });
14
+ nuxt.options.alias[`#${moduleName}`] = nuxtAliasPath(moduleName, nuxt);
15
+ addServerHandler({
16
+ handler: resolver.resolve('./handler')
17
+ });
18
+ });
@@ -1,79 +1,31 @@
1
- import * as babel from '@babel/core';
2
- import traverse from '@babel/traverse';
3
- import map from "@dword-design/functions/dist/map.js";
4
- import some from "@dword-design/functions/dist/some.js";
5
- import uniq from "@dword-design/functions/dist/uniq.js";
1
+ import { installModule } from '@nuxt/kit';
6
2
  import packageName from 'depcheck-package-name';
7
- import fs from 'fs-extra';
8
3
  import { globby } from 'globby';
9
4
  import P from 'path';
10
- import * as vueTemplateCompiler from 'vue-template-compiler';
11
- import MissingNuxtI18nHeadError from "./missing-nuxt-i18n-head-error.js";
12
- const checkNuxtI18nHead = async () => {
13
- var _ref, _ref2, _layoutFiles;
14
- const layoutFiles = (_ref = (_ref2 = ['default.vue', ...(await globby('*', {
15
- cwd: 'layouts',
16
- ignore: '-*'
17
- }))], await _ref2), uniq(_ref));
18
- const checkLayoutFile = async layoutFile => {
19
- var _layout$script;
20
- const layout = (await fs.exists(P.join('layouts', layoutFile))) ? vueTemplateCompiler.parseComponent(await fs.readFile(P.join('layouts', layoutFile), 'utf8')) : {};
21
- if ((_layout$script = layout.script) !== null && _layout$script !== void 0 && _layout$script.content) {
22
- var _layout$script2;
23
- const ast = await babel.parse((_layout$script2 = layout.script) === null || _layout$script2 === void 0 ? void 0 : _layout$script2.content, {
24
- filename: 'index.js'
25
- });
26
- let valid = false;
27
- traverse.default(ast, {
28
- ExportDefaultDeclaration: path => {
29
- var _path$node$declaratio;
30
- if (_path$node$declaratio = path.node.declaration.properties, some(property => {
31
- var _property$key, _property$body$body$, _property$body$body$2, _property$body$body$3;
32
- return property.type === 'ObjectMethod' && ((_property$key = property.key) === null || _property$key === void 0 ? void 0 : _property$key.name) === 'head' && property.body.body.length === 1 && property.body.body[0].type === 'ReturnStatement' && property.body.body[0].argument.type === 'CallExpression' && property.body.body[0].argument.callee.type === 'MemberExpression' && property.body.body[0].argument.callee.object.type === 'ThisExpression' && ((_property$body$body$ = property.body.body[0].argument.callee.property) === null || _property$body$body$ === void 0 ? void 0 : _property$body$body$.name) === '$nuxtI18nHead' && property.body.body[0].argument.arguments.length === 1 && property.body.body[0].argument.arguments[0].type === 'ObjectExpression' && property.body.body[0].argument.arguments[0].properties.length === 1 && ((_property$body$body$2 = property.body.body[0].argument.arguments[0].properties[0].key) === null || _property$body$body$2 === void 0 ? void 0 : _property$body$body$2.name) === 'addSeoAttributes' && ((_property$body$body$3 = property.body.body[0].argument.arguments[0].properties[0].value) === null || _property$body$body$3 === void 0 ? void 0 : _property$body$body$3.value) === true;
33
- })(_path$node$declaratio)) {
34
- valid = true;
35
- }
36
- }
37
- });
38
- if (valid) {
39
- return;
40
- }
41
- }
42
- throw new MissingNuxtI18nHeadError(layoutFile);
43
- };
44
- return Promise.all((_layoutFiles = layoutFiles, map(checkLayoutFile)(_layoutFiles)));
45
- };
46
- export default async function () {
47
- const localeFiles = await globby('*.json', {
48
- cwd: P.join(this.options.srcDir, 'i18n')
49
- });
50
- if (localeFiles.length > 0) {
51
- var _localeFiles;
52
- await checkNuxtI18nHead();
53
- await this.addModule([packageName`@nuxtjs/i18n`, {
54
- detectBrowserLanguage: localeFiles.length === 1 ? false : {
55
- fallbackLocale: 'en',
5
+ export default (async (options, nuxt) => {
6
+ const locales = (await globby('*.json', {
7
+ cwd: P.join(nuxt.options.srcDir, 'i18n')
8
+ })).map(filename => P.basename(filename, '.json'));
9
+ const defaultLocale = locales.includes('en') ? 'en' : locales[0];
10
+ if (locales.length > 0) {
11
+ await installModule(packageName`@nuxtjs/i18n`, {
12
+ defaultLocale,
13
+ detectBrowserLanguage: locales.length === 1 ? false : {
14
+ fallbackLocale: defaultLocale,
56
15
  redirectOn: 'no prefix',
57
16
  useCookie: false
58
17
  },
59
- langDir: 'i18n/',
18
+ langDir: 'i18n',
60
19
  lazy: true,
61
- locales: (_localeFiles = localeFiles, map(filename => {
62
- const code = P.basename(filename, '.json');
63
- return {
64
- code,
65
- file: filename,
66
- iso: code
67
- };
68
- })(_localeFiles)),
69
- seo: localeFiles.length > 1,
70
- strategy: localeFiles.length === 1 ? 'no_prefix' : 'prefix',
71
- ...(localeFiles.length === 1 && {
72
- defaultLocale: P.basename(localeFiles[0], '.json')
73
- }),
20
+ locales: locales.map(locale => ({
21
+ code: locale,
22
+ file: `${locale}.json`,
23
+ iso: locale
24
+ })),
25
+ strategy: `${locales.length === 1 ? 'no_' : ''}prefix`,
74
26
  ...(process.env.BASE_URL && {
75
27
  baseUrl: process.env.BASE_URL
76
28
  })
77
- }]);
29
+ });
78
30
  }
79
- }
31
+ });
@@ -1,14 +1,16 @@
1
- import { createRequire } from 'module';
2
- import nuxtPushPlugins from 'nuxt-push-plugins';
1
+ import { addPlugin, addTemplate, createResolver } from '@nuxt/kit';
3
2
  import P from 'path';
4
- const _require = createRequire(import.meta.url);
5
- export default function () {
6
- this.addTemplate({
7
- fileName: P.join('nuxt-locale-link', 'nuxt-locale-link.vue'),
8
- src: _require.resolve('./nuxt-locale-link.vue')
3
+ const resolver = createResolver(import.meta.url);
4
+ export default (() => {
5
+ addTemplate({
6
+ filename: P.join('nuxt-locale-link', 'component.vue'),
7
+ src: resolver.resolve('./component.vue'),
8
+ write: true
9
9
  });
10
- nuxtPushPlugins(this, {
11
- fileName: P.join('nuxt-locale-link', 'plugin.js'),
12
- src: _require.resolve('./plugin')
10
+ addPlugin({
11
+ filename: P.join('nuxt-locale-link', 'plugin.js'),
12
+ src: resolver.resolve('./plugin')
13
+ }, {
14
+ append: true
13
15
  });
14
- }
16
+ });
@@ -1,3 +1,3 @@
1
- import Vue from 'vue';
2
- import NuxtLocaleLink from "./nuxt-locale-link.vue";
3
- Vue.component('NuxtLocaleLink', NuxtLocaleLink);
1
+ import { defineNuxtPlugin } from '#imports';
2
+ import Component from "./component.vue";
3
+ export default defineNuxtPlugin(nuxtApp => nuxtApp.vueApp.component('NuxtLocaleLink', Component));
@@ -0,0 +1,5 @@
1
+ import svgLoader from 'vite-svg-loader';
2
+ export default ((moduleOptions, nuxt) => {
3
+ nuxt.options.vite.plugins = nuxt.options.vite.plugins || [];
4
+ nuxt.options.vite.plugins.push(svgLoader());
5
+ });
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import dotenv from '@dword-design/dotenv-json-extended';
3
+ import { execa } from 'execa';
4
+ dotenv.config();
5
+ execa('nuxt', process.argv.slice(2), {
6
+ env: {
7
+ NODE_ENV: ''
8
+ },
9
+ stdio: 'inherit'
10
+ });
@@ -1,22 +1,29 @@
1
1
  import { execa } from 'execa';
2
2
  import fs from 'fs-extra';
3
- import { Builder, Nuxt } from 'nuxt';
4
- import getNuxtConfig from "./get-nuxt-config.js";
3
+ import { createRequire } from 'module';
5
4
  import lint from "./lint.js";
5
+ const _require = createRequire(import.meta.url);
6
+ const nuxtWrapper = _require.resolve('./nuxt-wrapper.js');
6
7
  export default (async (options = {}) => {
8
+ options = {
9
+ log: process.env.NODE_ENV !== 'test',
10
+ ...options
11
+ };
7
12
  await lint();
8
- const nuxt = new Nuxt({
9
- ...getNuxtConfig(),
10
- _build: true,
11
- dev: false,
12
- rootDir: options.rootDir,
13
- server: false
13
+ await execa(nuxtWrapper, ['build'], {
14
+ ...(options.log ? {
15
+ stdio: 'inherit'
16
+ } : {}),
17
+ ...(process.env.NODE_ENV === 'test' ? {
18
+ env: {
19
+ NUXT_TELEMETRY_DISABLED: 1
20
+ }
21
+ } : {})
14
22
  });
15
- await new Builder(nuxt).build();
16
23
  if (await fs.exists('model')) {
17
24
  await fs.remove('dist');
18
- await execa('babel', ['--out-dir', 'dist', '--copy-files', '--no-copy-ignored', '--ignore', '**/*.spec.js', 'model'], {
19
- stdio: options.log === false ? 'ignore' : 'inherit'
20
- });
25
+ await execa('babel', ['--out-dir', 'dist', '--copy-files', '--no-copy-ignored', '--ignore', '**/*.spec.js', 'model'], ...(options.log ? [{
26
+ stdio: 'inherit'
27
+ }] : []));
21
28
  }
22
29
  });
package/dist/start.js CHANGED
@@ -1,17 +1,13 @@
1
- import { Nuxt } from 'nuxt';
2
- import getNuxtConfig from "./get-nuxt-config.js";
3
- export default (async (options = {
4
- log: false
5
- }) => {
6
- const nuxt = new Nuxt({
7
- ...getNuxtConfig(),
8
- _start: true,
9
- build: {
10
- quiet: !options.log
11
- },
12
- dev: false,
13
- rootDir: options.rootDir
14
- });
15
- await nuxt.listen();
16
- return nuxt;
1
+ import { execa } from 'execa';
2
+ import { createRequire } from 'module';
3
+ const _require = createRequire(import.meta.url);
4
+ const nuxtWrapper = _require.resolve('./nuxt-wrapper.js');
5
+ export default ((options = {}) => {
6
+ options = {
7
+ log: process.env.NODE_ENV !== 'test',
8
+ ...options
9
+ };
10
+ return execa(nuxtWrapper, ['start'], ...(options.log ? [{
11
+ stdio: 'inherit'
12
+ }] : []));
17
13
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dword-design/base-config-nuxt",
3
- "version": "3.2.16",
3
+ "version": "4.0.0",
4
4
  "repository": "dword-design/base-config-nuxt",
5
5
  "funding": "https://github.com/sponsors/dword-design",
6
6
  "license": "MIT",
@@ -19,22 +19,18 @@
19
19
  "lint": "base lint",
20
20
  "prepare": "base prepare",
21
21
  "prepublishOnly": "base prepublishOnly",
22
- "test": "base test",
23
- "test:raw": "base test:raw"
22
+ "test": "base test"
24
23
  },
25
24
  "dependencies": {
26
- "@babel/core": "^7.16.0",
27
- "@babel/traverse": "^7.16.3",
28
- "@dword-design/babel-config": "^2.1.1",
29
25
  "@dword-design/depcheck-parser-sass": "^3.0.0",
30
26
  "@dword-design/dotenv-json-extended": "^2.0.0",
31
- "@dword-design/eslint-config": "^3.0.1",
32
27
  "@dword-design/functions": "^4.0.0",
28
+ "@dword-design/jiti-babel-transform": "^1.0.11",
33
29
  "@dword-design/stylelint-config": "^2.0.0",
34
- "@nuxtjs/axios": "^5.10.3",
35
- "@nuxtjs/eslint-module": "^3.0.0",
36
- "@nuxtjs/i18n": "7.3.1",
37
- "@nuxtjs/stylelint-module": "^4.0.0",
30
+ "@nuxt/kit": "^3.2.3",
31
+ "@nuxtjs/eslint-module": "^4.1.0",
32
+ "@nuxtjs/i18n": "npm:@dword-design/nuxt-i18n",
33
+ "@nuxtjs/stylelint-module": "^5.0.1",
38
34
  "depcheck-package-name": "^3.0.0",
39
35
  "depcheck-parser-vue": "^3.0.1",
40
36
  "execa": "^6.1.0",
@@ -42,36 +38,34 @@
42
38
  "express-mount-files": "npm:@dword-design/express-mount-files",
43
39
  "fs-extra": "^11.1.0",
44
40
  "globby": "^13.1.3",
45
- "jiti": "npm:@dword-design/jiti",
46
- "nuxt": "~2.16.0",
47
- "nuxt-babel-runtime": "^3.0.0",
48
- "nuxt-basic-auth-module": "^1.4.1",
49
- "nuxt-push-plugins": "^2.0.0",
50
- "nuxt-svg-loader": "^1.2.0",
51
- "promise-sequential": "^1.1.1",
52
- "raw-loader": "^4.0.1",
53
- "sass": "^1.34.0",
54
- "sass-loader": "^10.0.0",
41
+ "jiti": "^1.18.2",
42
+ "nuxt": "^3.2.3",
43
+ "nuxt-alias-path": "^1.0.0",
44
+ "nuxt-basic-authentication-module": "^0.2.1",
45
+ "output-files": "^2.0.0",
55
46
  "stylelint": "^13.6.0",
56
- "vue": "^2.6.11",
57
- "vue-template-compiler": "^2.6.14"
47
+ "vite-svg-loader": "^4.0.0"
58
48
  },
59
49
  "devDependencies": {
60
- "@dword-design/base": "^9.0.0",
50
+ "@dword-design/base": "^10.0.0",
61
51
  "@dword-design/puppeteer": "^6.0.0",
62
52
  "@dword-design/tester": "^2.0.9",
63
- "@dword-design/tester-plugin-env": "^2.0.8",
64
53
  "@dword-design/tester-plugin-puppeteer": "^2.1.19",
65
54
  "@dword-design/tester-plugin-tmp-dir": "^2.1.3",
66
- "@nuxtjs/sitemap": "^2.4.0",
55
+ "@funken-studio/sitemap-nuxt-3": "^4.0.4",
67
56
  "axios": "^0.22.0",
68
57
  "depcheck": "^1.4.2",
69
- "output-files": "^2.0.0",
58
+ "nuxt-dev-ready": "^2.0.0",
59
+ "p-all": "^5.0.0",
70
60
  "port-ready": "^0.1.0",
61
+ "tree-kill-promise": "^3.0.1",
71
62
  "xml-formatter": "^3.2.0"
72
63
  },
64
+ "peerDependencies": {
65
+ "h3": "*"
66
+ },
73
67
  "engines": {
74
- "node": ">=14"
68
+ "node": ">=16"
75
69
  },
76
70
  "publishConfig": {
77
71
  "access": "public"
@@ -1,9 +0,0 @@
1
- import dotenv from '@dword-design/dotenv-json-extended';
2
- import projectModule from "./modules/project/index.js";
3
- export default (() => {
4
- dotenv.config();
5
- return {
6
- modules: [projectModule],
7
- telemetry: true
8
- };
9
- });
@@ -1,6 +0,0 @@
1
- import { createRequire } from 'module';
2
- import nuxtPushPlugins from 'nuxt-push-plugins';
3
- const _require = createRequire(import.meta.url);
4
- export default function () {
5
- nuxtPushPlugins(this, _require.resolve('./plugin'));
6
- }
@@ -1,5 +0,0 @@
1
- export default (context => {
2
- if (process.client) {
3
- context.$axios.defaults.baseURL = window.location.origin;
4
- }
5
- });
@@ -1,3 +0,0 @@
1
- export default function () {
2
- this.options.build.babel.babelrc = true;
3
- }
@@ -1,6 +0,0 @@
1
- import express from 'express';
2
- export default function () {
3
- this.options.serverMiddleware.push(...[express.json(), express.urlencoded({
4
- extended: false
5
- })]);
6
- }
@@ -1,4 +0,0 @@
1
- export default function () {
2
- this.options.build.loaders.cssModules.modules.localIdentName = this.options.dev ? '[name]__[local]' : '[hash:base64]';
3
- this.options.build.loaders.cssModules.modules.exportLocalsConvention = 'camelCase';
4
- }
@@ -1,6 +0,0 @@
1
- import dotenv from '@dword-design/dotenv-json-extended';
2
- import P from 'path';
3
- export default function () {
4
- dotenv.config();
5
- this.options.watch.push(P.join(this.options.rootDir, '.env.json'), P.join(this.options.rootDir, '.env.schema.json'));
6
- }
@@ -1,17 +0,0 @@
1
- import endent from "@dword-design/functions/dist/endent.js";
2
- import P from 'path';
3
- export default class extends Error {
4
- constructor(layoutFile) {
5
- super(endent`
6
- You have to implement $nuxtI18nHead in ${P.join('layouts', layoutFile)} like this to make sure that i18n metadata are generated:
7
-
8
- <script>
9
- export default {
10
- head () {
11
- return this.$nuxtI18nHead({ addSeoAttributes: true })
12
- }
13
- }
14
- </script>
15
- `);
16
- }
17
- }
@@ -1,10 +0,0 @@
1
- import packageName from 'depcheck-package-name';
2
- export default function () {
3
- this.extendBuild(config => {
4
- config.module.rules.push({
5
- exclude: /node_modules/,
6
- loader: packageName`raw-loader`,
7
- test: /\.(txt|html)$/
8
- });
9
- });
10
- }
@@ -1,29 +0,0 @@
1
- import babelConfig from '@dword-design/babel-config';
2
- import express from 'express';
3
- import mountFiles from 'express-mount-files';
4
- import P from 'path';
5
- export default async function (options) {
6
- // Make sure that we do not register the server middleware
7
- // on build because processes like express-mysql-session do
8
- // not get closed
9
- // https://github.com/nuxt/nuxt.js/blob/2ec62617ced873fef97c73a6d7aa1271911ccfd5/packages/core/src/nuxt.js#L56
10
- if (this.options.server !== false) {
11
- var _options$getExpress;
12
- const app = (await ((_options$getExpress = options.getExpress) === null || _options$getExpress === void 0 ? void 0 : _options$getExpress.call(options))) || express();
13
- app.use(mountFiles(P.join(this.options.srcDir, 'api'), {
14
- jitiOptions: {
15
- esmResolve: true,
16
- interopDefault: true,
17
- transformOptions: {
18
- babel: babelConfig
19
- }
20
- },
21
- paramChar: '_'
22
- }));
23
- this.addServerMiddleware({
24
- handler: app,
25
- path: '/api'
26
- });
27
- this.options.watch.push(P.join(this.options.srcDir, 'api'));
28
- }
29
- }
@@ -1,3 +0,0 @@
1
- .__nuxt-error-page {
2
- position: static;
3
- }