保誠-保戶業務員媒合平台
Tomas
2022-05-19 957a1f10a06fdbb76f1a0ba94fe44126c613fee3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*!
 * @nuxt/cli v2.15.8 (c) 2016-2021
 * Released under the MIT License
 * Repository: https://github.com/nuxt/nuxt.js
 * Website: https://nuxtjs.org
*/
'use strict';
 
const consola = require('consola');
const utils = require('@nuxt/utils');
const index = require('./cli-index.js');
require('@nuxt/config');
require('path');
require('exit');
require('chalk');
require('std-env');
require('wrap-ansi');
require('boxen');
require('minimist');
require('hable');
require('defu');
require('semver');
require('fs');
require('execa');
 
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
 
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
 
const build = {
  name: 'build',
  description: 'Compiles the application for production deployment',
  usage: 'build <dir>',
  options: {
    ...index.common,
    ...index.locking,
    analyze: {
      alias: 'a',
      type: 'boolean',
      description: 'Launch webpack-bundle-analyzer to optimize your bundles',
      prepare (cmd, options, argv) {
        // Analyze option
        options.build = options.build || {};
        if (argv.analyze && typeof options.build.analyze !== 'object') {
          options.build.analyze = true;
        }
      }
    },
    devtools: {
      type: 'boolean',
      default: false,
      description: 'Enable Vue devtools',
      prepare (cmd, options, argv) {
        options.vue = options.vue || {};
        options.vue.config = options.vue.config || {};
        if (argv.devtools) {
          options.vue.config.devtools = true;
        }
      }
    },
    generate: {
      type: 'boolean',
      default: true,
      description: 'Don\'t generate static version for SPA mode (useful for nuxt start)'
    },
    quiet: {
      alias: 'q',
      type: 'boolean',
      description: 'Disable output except for errors',
      prepare (cmd, options, argv) {
        // Silence output when using --quiet
        options.build = options.build || {};
        if (argv.quiet) {
          options.build.quiet = Boolean(argv.quiet);
        }
      }
    },
    standalone: {
      type: 'boolean',
      default: false,
      description: 'Bundle all server dependencies (useful for nuxt-start)',
      prepare (cmd, options, argv) {
        if (argv.standalone) {
          options.build.standalone = true;
        }
      }
    }
  },
  async run (cmd) {
    const config = await cmd.getNuxtConfig({ dev: false, server: false, _build: true });
    config.server = (config.mode === utils.MODES.spa || config.ssr === false) && cmd.argv.generate !== false;
    const nuxt = await cmd.getNuxt(config);
 
    if (cmd.argv.lock) {
      await cmd.setLock(await index.createLock({
        id: 'build',
        dir: nuxt.options.buildDir,
        root: config.rootDir
      }));
    }
 
    // TODO: remove if in Nuxt 3
    if (nuxt.options.mode === utils.MODES.spa && nuxt.options.target === utils.TARGETS.server && cmd.argv.generate !== false) {
      // Build + Generate for static deployment
      const generator = await cmd.getGenerator(nuxt);
      await generator.generate({ build: true });
    } else {
      // Build only
      const builder = await cmd.getBuilder(nuxt);
      await builder.build();
 
      const nextCommand = nuxt.options.target === utils.TARGETS.static ? 'nuxt generate' : 'nuxt start';
      consola__default['default'].info('Ready to run `' + (nextCommand) + '`');
    }
  }
};
 
exports.default = build;