build.js 882 B

1234567891011121314151617181920212223242526272829303132
  1. const path = require('path')
  2. const ora = require('ora')
  3. const rm = require('rimraf')
  4. const chalk = require('chalk')
  5. const copy = require('copy')
  6. const webpack = require('webpack')
  7. const config = require('./webpack.conf')
  8. const pkg = require('../package.json')
  9. const rootPath = path.resolve(__dirname, '../')
  10. new Promise((resolve, reject) => {
  11. // 构建全量压缩包
  12. let building = ora('building...')
  13. building.start()
  14. rm(path.resolve(rootPath, 'build', `${pkg.name}.min.js`), err => {
  15. if (err) throw (err)
  16. webpack(config, function (err, stats) {
  17. if (err) throw (err)
  18. building.stop()
  19. process.stdout.write(stats.toString({
  20. colors: true,
  21. modules: false,
  22. children: false,
  23. chunks: false,
  24. chunkModules: false
  25. }) + '\n\n')
  26. resolve()
  27. console.log(chalk.cyan(' Build complete.\n'))
  28. })
  29. })
  30. })