1 | const path = require('path')
|
2 | const chalk = require('chalk')
|
3 | const copyAll = require('./copy-all')
|
4 | const compressImages = require('./compress-images')
|
5 |
|
6 | module.exports = ({ env, program }) => {
|
7 | const distPath = path.join(program.cwd, '/dist')
|
8 | const srcPath = path.join(program.cwd, './src')
|
9 | const imagesArgs = [srcPath, distPath, {
|
10 | dir: 'images',
|
11 | emoji: '🏔',
|
12 | filter: /.*\.(png|jpg|gif|svg)$/
|
13 | }]
|
14 | return Promise.all([
|
15 | env.skipCompressImages ? copyAll(...imagesArgs) : compressImages(...imagesArgs),
|
16 | copyAll(srcPath, distPath, {
|
17 | dir: 'sounds',
|
18 | emoji: '🔈',
|
19 | filter: /.*\.(mp3|wav|vtt)$/
|
20 | }),
|
21 | copyAll(srcPath, distPath, {
|
22 | dir: 'components',
|
23 | emoji: '📦'
|
24 | }),
|
25 | copyAll(srcPath, distPath, {
|
26 | dir: 'fonts',
|
27 | filter: /.*\.(woff|ttf|woff2|otf|css)$/,
|
28 | emoji: '🅰️'
|
29 | }),
|
30 | copyAll(srcPath, distPath, {
|
31 | dir: 'json',
|
32 | filter: /.*\.(json)$/,
|
33 | emoji: '🖊'
|
34 | })
|
35 | ])
|
36 | .catch((reason) => {
|
37 | console.log(chalk.red('⚠️ copy did NOT complete'))
|
38 | return Promise.reject(reason)
|
39 | })
|
40 | }
|