Total Complexity | 5 |
Complexity/F | 2.5 |
Lines of Code | 41 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |
||
|
|||
19 | webpack(webpackConfig, (err, stats) => { |
||
20 | spinner.stop() |
||
21 | if (err) throw err |
||
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')) |
||
32 | process.exit(1) |
||
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 |
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 you or someone else later decides to put another statement in, only the first statement will be executed.
In this case the statement
b = 42
will always be executed, while the logging statement will be executed conditionally.ensures that the proper code will be executed conditionally no matter how many statements are added or removed.