| 53 | }; |
| 54 | |
| 55 | function buildCache(callback, isAutoRun = false, cacheType = 'nope') { |
| 56 | console.log('Building common chunks (cache), this may take a while...'); |
| 57 | |
| 58 | if (cacheType === 'initial') { |
| 59 | console.log( |
| 60 | chalk.gray('No previous cache was found, first time cache will take longer time than normal!\n'), |
| 61 | chalk.gray('Grab a cup of coffee and enjoy while waiting for this ;)\n')); |
| 62 | } else if (cacheType === 'changed') { |
| 63 | console.log(chalk.gray('Dependency change detected, rebuilding cache..\n')); |
| 64 | } else if (cacheType === 'force') { |
| 65 | console.log(chalk.gray('Using force option, building cache..\n')); |
| 66 | } |
| 67 | |
| 68 | setTimeout(() => { |
| 69 | const vendorConfigs = require('../tools/webpack.vendor'), |
| 70 | compiler = webpack(vendorConfigs); |
| 71 | |
| 72 | compiler.run((error, stats) => { |
| 73 | if (error) console.log(error); |
| 74 | else { |
| 75 | const currentPackageJson = require(paths.packageJson); |
| 76 | |
| 77 | mkdirp.sync(paths.ruui); |
| 78 | fs.writeFileSync(paths.ruuiJson, JSON.stringify({ |
| 79 | ...configs.ruuiJson, |
| 80 | dependencies: currentPackageJson.dependencies || {}, |
| 81 | devDependencies: currentPackageJson.devDependencies || {}, |
| 82 | }, null, 2)); |
| 83 | |
| 84 | if (lodash.isFunction(callback)) callback(); |
| 85 | } |
| 86 | }); |
| 87 | }, 0); |
| 88 | } |
| 89 | |
| 90 | function foundDependencyChange(currentDeps, previousDeps, excludes = []) { |
| 91 | const currentClone = { ...currentDeps }, |