Completed
Branch vue-dev (285fcd)
by Seth
41s
created

build.js ➔ ... ➔ ???   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 22
rs 9.2
1
'use strict'
2
require('./check-versions')()
3
4
process.env.NODE_ENV = 'production'
5
6
const ora = require('ora')
7
const rm = require('rimraf')
8
const path = require('path')
9
const chalk = require('chalk')
10
const webpack = require('webpack')
11
const config = require('../config')
12
const webpackConfig = require('./webpack.prod.conf')
13
14
const spinner = ora('building for production...')
15
spinner.start()
16
17
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18
  if (err) throw err
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
19
  webpack(webpackConfig, (err, stats) => {
20
    spinner.stop()
21
    if (err) throw err
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
22
    process.stdout.write(stats.toString({
23
      colors: true,
24
      modules: false,
25
      children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
26
      chunks: false,
27
      chunkModules: false
28
    }) + '\n\n')
29
30
    if (stats.hasErrors()) {
31
      console.log(chalk.red('  Build failed with errors.\n'))
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
32
      process.exit(1)
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
33
    }
34
35
    console.log(chalk.cyan('  Build complete.\n'))
36
    console.log(chalk.yellow(
37
      '  Tip: built files are meant to be served over an HTTP server.\n' +
38
      '  Opening index.html over file:// won\'t work.\n'
39
    ))
40
  })
41
})
42